PluginCxFreeze.py

Sun, 13 Feb 2011 17:09:10 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 13 Feb 2011 17:09:10 +0100
changeset 18
7a6fc748930f
parent 17
b5f6e6ca8b1a
child 21
de49f07bb6bf
permissions
-rw-r--r--

Updated Russian translations and added Italian translations.

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

eric ide

mercurial