-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·57 lines (48 loc) · 1.37 KB
/
Copy pathmain.py
File metadata and controls
executable file
·57 lines (48 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# -*- coding: utf-8 -*-
from wox import Wox, WoxAPI
from netaddr import valid_ipv4
import pyperclip
import socket
import os
def json_wox(title, subtitle, icon, action=None, action_params=None, action_keep=None):
json = {
'Title': title,
'SubTitle': subtitle,
'IcoPath': icon
}
if action and action_params and action_keep:
json.update({
'JsonRPCAction': {
'method': action,
'parameters': action_params,
'dontHideAfterAction': action_keep
}
})
return json
def copy_to_clipboard(text):
pyperclip.copy(text.strip())
def WhoIs(query):
try:
if not valid_ipv4(query):
host = socket.gethostbyname(query)
else:
host = socket.gethostbyaddr(query)[0]
except Exception as e:
host = e
results = []
results.append(json_wox(host,
'Query: {}'.format(query),
'Images/app.icog',
'copy_clip',
[str(host)],
True))
return results
class Who_Is(Wox):
def query(self, query):
return WhoIs(query)
def copy_clip(self, query):
#copy to clipboard after pressing enter
copy_to_clipboard(query)
WoxAPI.hide_app()
if __name__ == "__main__":
Who_Is()