-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
149 lines (131 loc) · 5.53 KB
/
Copy pathsetup.py
File metadata and controls
149 lines (131 loc) · 5.53 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
from setuptools import setup
print("####################################################")
print(" Starting Installation of SaxsDog")
print("####################################################")
versionstring="3.0"
setup(
name="SAXS",
version=versionstring,
packages=["SAXS"],
package_data={"SAXS": ["icons/*",
"schema.json",
"schema_1.json",
"LeashRequestSchema.json",
"LeashResultSchema.json",
"NetworkSchema.json",
"LeashMW.ui",
"importdialog.ui",
"DataConsolidationConf.json",
"consolconftemplate.json"
]},
author="Christian Meisenbichler",
author_email="chmberg@gmail.com",
description="Tools for analysing SAXS Data",
scripts =["postinstall.py"],
install_requires=["numpy",
"scipy",
"matplotlib",
"jsonschema",
"bitarray",
"watchdog",
"sphinxcontrib-programoutput",
"sphinxcontrib-programscreenshot",
"pyzmq", "prettyplotlib",
"pandas",
'winshell;platform_system=="Windows"'],
license="Proprietary",
entry_points = {
'console_scripts': [
'saxsconverter = SAXS:convert',
'saxsdog = SAXS:saxsdog',
'plotchi=SAXS:plotchi',
'saxsdogserver = SAXS:launcher',
'saxsleash =SAXS:saxsleash',
'saxsfeeder=SAXS:saxsfeeder',
"saxsnetconf=SAXS:gennetconf",
"saxsdmerge=SAXS:merge"
],
'gui_scripts':[
'leash=SAXS:LeashGUI'
]
}
)
try:
import py2exe
except:
print("No py2exe here")
def get_reg(name,path):
# Read variable from Windows Registry
# From https://stackoverflow.com/a/35286642
try:
registry_key = wr.OpenKey(wr.HKEY_CURRENT_USER, path, 0,
wr.KEY_READ)
value, regtype = wr.QueryValueEx(registry_key, name)
wr.CloseKey(registry_key)
return value
except WindowsError:
return None
from subprocess import call
import sys, os
if sys.argv[1] == 'install':
if os.name == "nt":
import winreg as wr
pyw_executable = os.path.join(sys.prefix, 'pythonw.exe')
script_file = '"'+os.path.join(sys.prefix, "Scripts", "leash-script.pyw")+'"'
iconpath= os.path.expanduser(
os.path.join(
sys.prefix,
"Lib",
"site-packages",
"SAXS-3.0-py3.5.egg",
"SAXS",
"icons",
"program.ico"))
wr.SetValue(wr.HKEY_CURRENT_USER, "Software\Classes\TUG.Leash\shell\open\command", wr.REG_SZ, pyw_executable+" \""+ script_file+ "\" \"%1\"")
wr.SetValue( wr.HKEY_CURRENT_USER, "Software\Classes\TUG.Leash\DefaultIcon", wr.REG_SZ, iconpath)
wr.SetValue( wr.HKEY_CURRENT_USER, "Software\Classes\.saxsconf", wr.REG_SZ, "TUG.Leash");
print("added registry values for extensions")
#import winshell
import win32com.client
w_dir = os.path.expanduser('~')
regName = 'Desktop'
regPath = r'Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders'
desktop_path = os.path.normpath(get_reg(regName,regPath))
#desktop_path = os.path.expanduser("~/Desktop")
#startmenu_path =win32com.shell.shell.SHGetSpecialFolderPath(0, win32com.shell.shellcon.CSIDL_STARTMENU)
regName = 'Start Menu'
startmenu_path = os.path.normpath(get_reg(regName,regPath))
print(" ")
print(" ")
print("####################################################")
print(" ")
print("Shortcuts for SAXSleash created at:")
'''Startmenu Shortcut'''
shell = win32com.client.Dispatch("WScript.Shell")
startmenu_path = startmenu_path.replace("%USERPROFILE%",os.environ['USERPROFILE'])
linklocation = os.path.join(startmenu_path, 'SAXSLeash.lnk')
link = shell.CreateShortCut(linklocation)
link.TargetPath = pyw_executable
link.Description = "Control panel for SAXSdog Server"
link.Arguments = script_file
link.IconLocation =iconpath
link.save()
print(" -) Start Menu: "+linklocation)
'''Startmenu Shortcut'''
desktop_path = desktop_path.replace("%USERPROFILE%",os.environ['USERPROFILE'])
linklocation = os.path.join(desktop_path, 'SAXSLeash.lnk')
link = shell.CreateShortCut(linklocation)
link.TargetPath = pyw_executable
link.Description = "Control panel for SAXSdog Server"
link.Arguments = script_file
link.IconLocation =iconpath
link.save()
print(" -) Dektop: "+linklocation)
print(" ")
call(["ie4uinit.exe", "-ClearIconCache"])
elif os.name == "posix":
print(os.name)
call(["bash", "addmime.sh"])
print("####################################################")
print(" SaxsDog Installation done!")
print("####################################################")