Fri, 29 Apr 2011 08:55:22 +0200
Fixed the cxfreeze search algorithm to check a per user install as well.
25
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
2 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
3 | # Copyright (c) 2010 - 2011 Detlev Offenbach <detlev@die-offenbachs.de> |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
4 | # |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
5 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
6 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
7 | Module implementing the CxFreeze plugin. |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
8 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
9 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
10 | import os |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
11 | import sys |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
12 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
13 | from PyQt4.QtCore import QObject, QTranslator, QCoreApplication |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
14 | from PyQt4.QtGui import QDialog, QMessageBox |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
15 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
16 | from E5Gui.E5Action import E5Action |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
17 | from E5Gui.E5Application import e5App |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
18 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
19 | from CxFreeze.CxfreezeConfigDialog import CxfreezeConfigDialog |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
20 | from CxFreeze.CxfreezeExecDialog import CxfreezeExecDialog |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
21 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
22 | import Utilities |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
23 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
24 | # Start-of-Header |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
25 | name = "CxFreeze Plugin" |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
26 | author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
27 | autoactivate = True |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
28 | deactivateable = True |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
29 | version = "5.0.4" |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
30 | className = "CxFreezePlugin" |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
31 | packageName = "CxFreeze" |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
32 | shortDescription = "Show the CxFreeze dialogs." |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
33 | longDescription = """This plugin implements the CxFreeze dialogs.""" \ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
34 | """ CxFreeze is used to generate a distribution package.""" |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
35 | needsRestart = False |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
36 | pyqtApi = 2 |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
37 | # End-of-Header |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
38 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
39 | error = "" |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
40 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
41 | def exeDisplayData(): |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
42 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
43 | Public method to support the display of some executable info. |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
44 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
45 | @return dictionary containing the data to query the presence of |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
46 | the executable |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
47 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
48 | data = { |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
49 | "programEntry" : True, |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
50 | "header" : QCoreApplication.translate("CxFreezePlugin", |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
51 | "Packagers - cx_freeze"), |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
52 | "exe" : 'dummyfreeze', |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
53 | "versionCommand" : '--version', |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
54 | "versionStartsWith" : 'dummyfreeze', |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
55 | "versionPosition" : -1, |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
56 | "version" : "", |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
57 | "versionCleanup" : None, |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
58 | } |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
59 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
60 | exe = _findExecutable() |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
61 | if exe: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
62 | data["exe"] = exe |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
63 | if "FreezePython" in exe: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
64 | data["versionStartsWith"] = "FreezePython" |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
65 | elif "cxfreeze" in exe: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
66 | data["versionStartsWith"] = "cxfreeze" |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
67 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
68 | return data |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
69 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
70 | def _findExecutable(): |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
71 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
72 | Restricted function to determine the name of the executable. |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
73 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
74 | @return name of the executable (string) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
75 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
76 | # step 1: check for version 4.x |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
77 | if Utilities.isWindowsPlatform(): |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
78 | # |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
79 | # Windows |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
80 | # |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
81 | exe = 'cxfreeze.bat' |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
82 | if Utilities.isinpath(exe): |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
83 | return exe |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
84 | try: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
85 | #only since python 3.2 |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
86 | import sysconfig |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
87 | scripts = sysconfig.get_path('scripts','nt') |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
88 | return os.path.join(scripts, exe) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
89 | except ImportError: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
90 | try: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
91 | import winreg |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
92 | except ImportError: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
93 | # give up ... |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
94 | return None |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
95 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
96 | def getExePath(branch): |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
97 | version = str(sys.version_info.major) + '.' + \ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
98 | str(sys.version_info.minor) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
99 | try: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
100 | software = winreg.OpenKey(branch, 'Software') |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
101 | python = winreg.OpenKey(software, 'Python') |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
102 | pcore = winreg.OpenKey(python, 'PythonCore') |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
103 | version = winreg.OpenKey(pcore, version) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
104 | installpath = winreg.QueryValue(version, 'InstallPath') |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
105 | return os.path.join(installpath, 'Scripts', exe) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
106 | except WindowsError: # __IGNORE_WARNING__ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
107 | return None |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
108 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
109 | exePath = getExePath(winreg.HKEY_CURRENT_USER) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
110 | if not exePath: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
111 | exePath = getExePath(winreg.HKEY_LOCAL_MACHINE) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
112 | return exePath |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
113 | else: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
114 | # |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
115 | # Linux, Unix ... |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
116 | exe = 'cxfreeze' |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
117 | if Utilities.isinpath(exe): |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
118 | return exe |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
119 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
120 | return None |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
121 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
122 | def _checkProgram(): |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
123 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
124 | Restricted function to check the availability of cxfreeze. |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
125 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
126 | @return flag indicating availability (boolean) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
127 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
128 | global error |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
129 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
130 | if _findExecutable() is None: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
131 | error = QCoreApplication.translate("CxFreezePlugin", |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
132 | "The cxfreeze executable could not be found.") |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
133 | return False |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
134 | else: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
135 | return True |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
136 | _checkProgram() |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
137 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
138 | class CxFreezePlugin(QObject): |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
139 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
140 | Class implementing the CxFreeze plugin. |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
141 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
142 | def __init__(self, ui): |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
143 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
144 | Constructor |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
145 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
146 | @param ui reference to the user interface object (UI.UserInterface) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
147 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
148 | QObject.__init__(self, ui) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
149 | self.__ui = ui |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
150 | self.__initialize() |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
151 | _checkProgram() |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
152 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
153 | self.__translator = None |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
154 | self.__loadTranslator() |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
155 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
156 | def __initialize(self): |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
157 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
158 | Private slot to (re)initialize the plugin. |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
159 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
160 | self.__projectAct = None |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
161 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
162 | def activate(self): |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
163 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
164 | Public method to activate this plugin. |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
165 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
166 | @return tuple of None and activation status (boolean) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
167 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
168 | global error |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
169 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
170 | # cxfreeze is only activated if it is available |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
171 | if not _checkProgram(): |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
172 | return None, False |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
173 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
174 | menu = e5App().getObject("Project").getMenu("Packagers") |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
175 | if menu: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
176 | self.__projectAct = E5Action(self.trUtf8('Use cx_freeze'), |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
177 | self.trUtf8('Use cx_&freeze'), 0, 0, |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
178 | self, 'packagers_cxfreeze') |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
179 | self.__projectAct.setStatusTip( |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
180 | self.trUtf8('Generate a distribution package using cx_freeze')) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
181 | self.__projectAct.setWhatsThis(self.trUtf8( |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
182 | """<b>Use cx_freeze</b>""" |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
183 | """<p>Generate a distribution package using cx_freeze.""" |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
184 | """ The command is executed in the project path. All""" |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
185 | """ files and directories must be given absolute or""" |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
186 | """ relative to the project directory.</p>""" |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
187 | )) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
188 | self.__projectAct.triggered[()].connect(self.__cxfreeze) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
189 | e5App().getObject("Project").addE5Actions([self.__projectAct]) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
190 | menu.addAction(self.__projectAct) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
191 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
192 | error = "" |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
193 | return None, True |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
194 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
195 | def deactivate(self): |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
196 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
197 | Public method to deactivate this plugin. |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
198 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
199 | menu = e5App().getObject("Project").getMenu("Packagers") |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
200 | if menu: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
201 | if self.__projectAct: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
202 | menu.removeAction(self.__projectAct) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
203 | e5App().getObject("Project").removeE5Actions([self.__projectAct]) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
204 | self.__initialize() |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
205 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
206 | def __loadTranslator(self): |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
207 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
208 | Private method to load the translation file. |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
209 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
210 | if self.__ui is not None: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
211 | loc = self.__ui.getLocale() |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
212 | if loc and loc != "C": |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
213 | locale_dir = \ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
214 | os.path.join(os.path.dirname(__file__), "CxFreeze", "i18n") |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
215 | translation = "cxfreeze_{0}".format(loc) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
216 | translator = QTranslator(None) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
217 | loaded = translator.load(translation, locale_dir) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
218 | if loaded: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
219 | self.__translator = translator |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
220 | e5App().installTranslator(self.__translator) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
221 | else: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
222 | print("Warning: translation file '{0}' could not be loaded."\ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
223 | .format(translation)) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
224 | print("Using default.") |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
225 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
226 | def __cxfreeze(self): |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
227 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
228 | Private slot to handle the cxfreeze execution. |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
229 | """ |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
230 | project = e5App().getObject("Project") |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
231 | if len(project.pdata["MAINSCRIPT"]) == 0: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
232 | # no main script defined |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
233 | QMessageBox.critical(None, |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
234 | self.trUtf8("cxfreeze"), |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
235 | self.trUtf8( |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
236 | """There is no main script defined for the current project."""), |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
237 | QMessageBox.StandardButtons( |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
238 | QMessageBox.Abort)) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
239 | return |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
240 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
241 | parms = project.getData('PACKAGERSPARMS', "CXFREEZE") |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
242 | exe = _findExecutable() |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
243 | if exe is None: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
244 | QMessageBox.critical(None, |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
245 | self.trUtf8("cxfreeze"), |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
246 | self.trUtf8("""The cxfreeze executable could not be found.""")) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
247 | return |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
248 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
249 | dlg = CxfreezeConfigDialog(project, exe, parms) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
250 | if dlg.exec_() == QDialog.Accepted: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
251 | args, parms = dlg.generateParameters() |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
252 | project.setData('PACKAGERSPARMS', "CXFREEZE", parms) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
253 | |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
254 | # now do the call |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
255 | dia = CxfreezeExecDialog("cxfreeze") |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
256 | dia.show() |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
257 | res = dia.start(args, |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
258 | os.path.join(project.ppath, project.pdata["MAINSCRIPT"][0])) |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
259 | if res: |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
260 | dia.exec_() |
737c623c90df
Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents:
24
diff
changeset
|
261 |