Commits

Rodrigo Pinheiro Matias committed 7e92032

corrigindo problemas com icones quando instalava atraves do easy_install ou pip

  • Participants
  • Parent commits 1f07968
  • Tags 0.1.4

Comments (0)

Files changed (13)

File QSupervisorControl.py

 limitations under the License.
 '''
 from PyQt4 import QtGui
-from PyQt4 import QtCore
-from supervisor import supervisorctl
-
-import os
-import sys
-import re
-
-try:
-    from cStringIO import StringIO
-except ImportError:
-    from StringIO import StringIO
-
-app_dir  = os.path.dirname(os.path.abspath(__file__))
-data_dir = os.path.join(app_dir, 'data')
-
-def proxy_func(func, *args, **kargs):
-    def wrapper():
-        func(*args, **kargs)
-    return wrapper
-
-class StatusObserve(QtCore.QThread):
-
-    def __init__(self, controller):
-        QtCore.QThread.__init__(self)
-        self._controller = controller
-
-    def run(self):
-        while True:
-            self._controller.emit(QtCore.SIGNAL('observe'))
-            self.sleep(1)
-
-class Controller(QtGui.QSystemTrayIcon):
-
-    def _void(self):
-        pass
-
-    def get_programs(self):
-        swap = sys.stdout
-        out = StringIO()
-        sys.stdout = out
-        supervisorctl.main(('status',))
-        sys.stdout = swap
-
-        for line in out.getvalue().split('\n'):
-            rst = re.match(r'^(?P<name>\w+)\s+(?P<status>\w+).*$', line.replace('\n', ''))
-            if rst is not None:
-                yield rst.groupdict()
-
-    def get_status(self, program):
-        swap = sys.stdout
-        out = StringIO()
-        sys.stdout = out
-        supervisorctl.main(('status', program))
-        sys.stdout = swap
-
-        rst = re.match(
-            r'^(?P<name>\w+)\s+(?P<status>\w+).*$', 
-            out.getvalue().replace('\n', '\0')
-        )
-
-        if rst is not None:
-            return rst.groupdict().get('status')
-        else:
-            return None
-
-    def _exit(self):
-        self._app.quit()
-
-    def do(self, program = 'all', action = None):
-        supervisorctl.main((action, program))
-
-    def register_to_observe(self, program, menu, action):
-        if hasattr(self, '_to_observe') is False:
-            self._to_observe = {}
-        if program not in self._to_observe.keys():
-            self._to_observe.update({
-                program: {
-                    'menu': menu,
-                    'action': action
-                }
-            })
-
-    def changeActionIcon(self, action, icon):
-        action.setIcon(QtGui.QIcon(os.path.join(data_dir, '%s.png' % icon.lower())))
-
-    def do_observe(self):
-        translate = {
-            'STOPPED': 'Parado',
-            'RUNNING': 'Rodando',
-            'FATAL': 'Falhou'
-        }
-
-        for program, info in self._to_observe.items():
-            status = self.get_status(program)
-            if status is not None:
-                info.get('action').setText(translate.get(status, 'Desconhecido'))
-                self.changeActionIcon(info.get('menu'), status)
-
-    def _createContextMenu(self):
-        menu = QtGui.QMenu()
-
-        menu.addAction('Iniciar todos', proxy_func(self.do, **{'action': 'start'}))
-        menu.addAction('Parar todos', proxy_func(self.do, **{'action': 'stop'}))
-        menu.addAction('Reiniciar todos', proxy_func(self.do, **{'action': 'restart'}))
-
-        menu.addSeparator()
-        for program in self.get_programs():
-            sub_menu = menu.addMenu(program.get('name').capitalize())
-            self.register_to_observe(
-                program.get('name'),
-                sub_menu,
-                sub_menu.addAction(program.get('status')),
-            )
-
-            sub_menu.addSeparator()
-            sub_menu.addAction('Iniciar', proxy_func(self.do, **{'program': program.get('name'),'action': 'start'}))
-            sub_menu.addAction('Parar', proxy_func(self.do, **{'program': program.get('name'),'action': 'stop'}))
-            sub_menu.addAction('Reiniciar', proxy_func(self.do, **{'program': program.get('name'),'action': 'restart'}))
-        menu.addSeparator()
-
-        menu.addAction('&Finalizar' + (' ' * 50), self._app.quit)
-
-        return menu
-
-    def __init__(self, app):
-        QtGui.QSystemTrayIcon.__init__(
-            self, 
-            QtGui.QIcon(os.path.join(data_dir, 'icon.png')),
-            app
-        )
-
-        self._app = app
-        self.setContextMenu(self._createContextMenu())
-        self._thread = StatusObserve(self)
-        QtCore.QObject.connect(self, QtCore.SIGNAL('observe'), self.do_observe)
-        self._thread.start()
+from QSupervisorControl import SupervisorController
 
 def main():
     app = QtGui.QApplication([])
     
-    ctl = Controller(app)
+    ctl = SupervisorController(app)
     ctl.show()
 
     app.exec_()

File QSupervisorControl/__init__.py

+# -*- coding: utf-8 -*-
+'''
+Copyright 2012 Rodrigo Pinheiro Matias <rodrigopmatias@gmail.com>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+'''
+from PyQt4 import QtGui
+from PyQt4 import QtCore
+from supervisor import supervisorctl
+
+import os
+import sys
+import re
+
+try:
+    from cStringIO import StringIO
+except ImportError:
+    from StringIO import StringIO
+
+app_dir  = os.path.dirname(os.path.abspath(__file__))
+data_dir = os.path.join(app_dir, 'data')
+
+def proxy_func(func, *args, **kargs):
+    def wrapper():
+        func(*args, **kargs)
+    return wrapper
+
+class StatusObserve(QtCore.QThread):
+
+    def __init__(self, controller):
+        QtCore.QThread.__init__(self)
+        self._controller = controller
+
+    def run(self):
+        while True:
+            self._controller.emit(QtCore.SIGNAL('observe'))
+            self.sleep(1)
+
+class SupervisorController(QtGui.QSystemTrayIcon):
+
+    def _void(self):
+        pass
+
+    def get_programs(self):
+        swap = sys.stdout
+        out = StringIO()
+        sys.stdout = out
+        supervisorctl.main(('status',))
+        sys.stdout = swap
+
+        for line in out.getvalue().split('\n'):
+            rst = re.match(r'^(?P<name>\w+)\s+(?P<status>\w+).*$', line.replace('\n', ''))
+            if rst is not None:
+                yield rst.groupdict()
+
+    def get_status(self, program):
+        swap = sys.stdout
+        out = StringIO()
+        sys.stdout = out
+        supervisorctl.main(('status', program))
+        sys.stdout = swap
+
+        rst = re.match(
+            r'^(?P<name>\w+)\s+(?P<status>\w+).*$', 
+            out.getvalue().replace('\n', '\0')
+        )
+
+        if rst is not None:
+            return rst.groupdict().get('status')
+        else:
+            return None
+
+    def _exit(self):
+        self._app.quit()
+
+    def do(self, program = 'all', action = None):
+        supervisorctl.main((action, program))
+
+    def register_to_observe(self, program, menu, action):
+        if hasattr(self, '_to_observe') is False:
+            self._to_observe = {}
+        if program not in self._to_observe.keys():
+            self._to_observe.update({
+                program: {
+                    'menu': menu,
+                    'action': action
+                }
+            })
+
+    def changeActionIcon(self, action, icon):
+        action.setIcon(QtGui.QIcon(os.path.join(data_dir, '%s.png' % icon.lower())))
+
+    def do_observe(self):
+        translate = {
+            'STOPPED': 'Parado',
+            'RUNNING': 'Rodando',
+            'FATAL': 'Falhou'
+        }
+
+        for program, info in self._to_observe.items():
+            status = self.get_status(program)
+            if status is not None:
+                info.get('action').setText(translate.get(status, 'Desconhecido'))
+                self.changeActionIcon(info.get('menu'), status)
+
+    def _createContextMenu(self):
+        menu = QtGui.QMenu()
+
+        menu.addAction('Iniciar todos', proxy_func(self.do, **{'action': 'start'}))
+        menu.addAction('Parar todos', proxy_func(self.do, **{'action': 'stop'}))
+        menu.addAction('Reiniciar todos', proxy_func(self.do, **{'action': 'restart'}))
+
+        menu.addSeparator()
+        for program in self.get_programs():
+            sub_menu = menu.addMenu(program.get('name').capitalize())
+            self.register_to_observe(
+                program.get('name'),
+                sub_menu,
+                sub_menu.addAction(program.get('status')),
+            )
+
+            sub_menu.addSeparator()
+            sub_menu.addAction('Iniciar', proxy_func(self.do, **{'program': program.get('name'),'action': 'start'}))
+            sub_menu.addAction('Parar', proxy_func(self.do, **{'program': program.get('name'),'action': 'stop'}))
+            sub_menu.addAction('Reiniciar', proxy_func(self.do, **{'program': program.get('name'),'action': 'restart'}))
+        menu.addSeparator()
+
+        menu.addAction('&Finalizar' + (' ' * 50), self._app.quit)
+
+        return menu
+
+    def __init__(self, app):
+        QtGui.QSystemTrayIcon.__init__(
+            self, 
+            QtGui.QIcon(os.path.join(data_dir, 'icon.png')),
+            app
+        )
+
+        self._app = app
+        self.setContextMenu(self._createContextMenu())
+        self._thread = StatusObserve(self)
+        QtCore.QObject.connect(self, QtCore.SIGNAL('observe'), self.do_observe)
+        self._thread.start()

File QSupervisorControl/__init__.pyc

Binary file added.

File QSupervisorControl/data/fatal.png

Added
New image

File QSupervisorControl/data/icon.png

Added
New image

File QSupervisorControl/data/running.png

Added
New image

File QSupervisorControl/data/stopped.png

Added
New image
-0.1.3
+0.1.4

File data/fatal.png

Removed
Old image

File data/icon.png

Removed
Old image

File data/running.png

Removed
Old image

File data/stopped.png

Removed
Old image
     py_modules = ['QSupervisorControl'],
     scripts = ['QSupervisorControl.py'],
     install_requires = ['supervisor'],
-    packages = ['data'],
-    package_data = {'data': ['data/*.png']}
+    packages = ['QSupervisorControl'],
+    package_data = {'QSupervisorControl': ['data/*.png']}
 )