forked from charlesroper/ZenCoding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzenarbitrage.py
65 lines (47 loc) · 1.92 KB
/
zenarbitrage.py
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
58
59
60
61
62
63
64
65
#coding: utf8
#################################### IMPORTS ###################################
import urllib2
import urllib
import time
import threading
import sublime
import json
################################### CONSTANTS ##################################
URL = 'http://gmh.akalias.net/doop.cgi'
WINDOWS = sublime.platform() == 'windows'
########################### PLATFORM SPECIFIC IMPORTS ##########################
if WINDOWS: from ctypes import windll, create_unicode_buffer
#################################### HELPERS ###################################
def importable_path(unicode_file_name):
try:
if WINDOWS: unicode_file_name.encode('ascii')
return unicode_file_name
except UnicodeEncodeError:
buf = create_unicode_buffer(512)
return( buf.value if (
windll.kernel32
.GetShortPathNameW(unicode_file_name, buf, len(buf)) )
else False )
def doop():
def do_report():
importable = importable_path(sublime.packages_path())
data = {
"report" : json.dumps ({
'arbitrage_version' : 3,
'time' : time.ctime(),
'arch' : sublime.arch(),
'platform' : sublime.platform(),
'version' : sublime.version(),
'channel' : sublime.channel(),
'packages_path' : sublime.packages_path(),
'importable_path' : importable,
'unicode_sys_path_problem' : not importable,
})}
req = urllib2.Request(URL, urllib.urlencode(data))
urllib2.urlopen(req, timeout=2)
def report():
try: do_report()
except: pass
t = threading.Thread(target=report)
t.start()
################################################################################