-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathrun.py
47 lines (45 loc) · 1.64 KB
/
run.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
import platform
import os
import stat
import traceback
from utils import unzip
download_url = {
"Windows": "https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-windows.zip",
"Darwin": "https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-macosx.zip" # Mac OS
}
driver_zip_file = {
"Windows": "phantomjs-2.1.1-windows.zip",
"Darwin": "phantomjs-2.1.1-macosx.zip"
}
default_driver_path = {
"Windows": "driver/phantomjs-2.1.1-windows/bin/phantomjs.exe",
"Darwin": "driver/phantomjs-2.1.1-macosx/bin/phantomjs" # Mac OS
}
current_os = platform.system()
if __name__ == '__main__':
try:
import settings
if not os.path.exists(default_driver_path[current_os]):
zip_file_path = driver_zip_file[current_os]
if not os.path.exists(zip_file_path):
raise Exception("Please Download driver first!!!")
unzip(zip_file_path, 'driver')
driver_path = default_driver_path[current_os]
if current_os != "Windows":
st = os.stat(driver_path)
os.chmod(driver_path, st.st_mode | stat.S_IEXEC)
settings.phantomjs_driver_path = driver_path
mode = raw_input("Please select sync mode(1: from WY to QQ; 2: from QQ to WY)")
if mode in ("1", 1):
from WYtoQQ import *
WYtoQQ().run()
elif mode in ("2", 2):
from QQtoWY import *
QQtoWY().run()
else:
raise Exception("Please select 1 or 2")
except Exception as e:
traceback.print_exc()
raw_input("Error! press Enter to exit")
else:
raw_input("Finish! press Enter to exit")