def _build_info_string(self): from lunchinator.utilities import getPlatform, PLATFORM_LINUX, PLATFORM_MAC, PLATFORM_WINDOWS info_d = {u"avatar": get_settings().get_avatar_file(), u"name": get_settings().get_user_name(), u"group": get_settings().get_group(), u"ID": get_settings().get_ID(), u"next_lunch_begin":get_settings().get_default_lunch_begin(), u"next_lunch_end":get_settings().get_default_lunch_end(), u"version":get_settings().get_version(), u"version_commit_count":get_settings().get_commit_count(), u"platform": sys.platform} try: if getPlatform() == PLATFORM_LINUX: info_d[u"os"] = u" ".join(aString if type(aString) in (str, unicode) else "[%s]" % " ".join(aString) for aString in platform.linux_distribution()) elif getPlatform() == PLATFORM_WINDOWS: info_d[u"os"] = u" ".join(aString if type(aString) in (str, unicode) else "[%s]" % " ".join(aString) for aString in platform.win32_ver()) elif getPlatform() == PLATFORM_MAC: info_d[u"os"] = u" ".join(aString if type(aString) in (str, unicode) else "[%s]" % " ".join(aString) for aString in platform.mac_ver()) except: getCoreLogger().exception("Error generating OS version string") if get_settings().get_next_lunch_begin(): info_d[u"next_lunch_begin"] = get_settings().get_next_lunch_begin() if get_settings().get_next_lunch_end(): info_d[u"next_lunch_end"] = get_settings().get_next_lunch_end() self.controller.extendMemberInfo(info_d) return json.dumps(info_d)
def _initLayout(self): layout = QVBoxLayout(self) layout.setContentsMargins(5, 5, 5, 5) layout.setSpacing(0) nameLayout = QHBoxLayout() nameLayout.setContentsMargins(0, 0, 0, 0) self._fileIconLabel = QLabel(self) nameLayout.addWidget(self._fileIconLabel, 0, Qt.AlignLeft) self._nameLabel = QLabel(self) nameLayout.addSpacing(5) nameLayout.addWidget(self._nameLabel, 1, Qt.AlignLeft) layout.addLayout(nameLayout) progressWidget = QWidget(self) progressLayout = QHBoxLayout(progressWidget) progressLayout.setSpacing(5) progressLayout.setContentsMargins(0, 0, 0, 0) iconLabel = QLabel(progressWidget) if self._down: picFile = get_settings().get_resource("images", "down.png") else: picFile = get_settings().get_resource("images", "up.png") iconLabel.setPixmap(QPixmap(picFile)) iconLabel.setFixedSize(15,15) progressLayout.addWidget(iconLabel, 0, Qt.AlignBottom) self._progress = QProgressBar(progressWidget) self._progress.setMinimum(0) self._progress.setMaximum(100) if getPlatform() == PLATFORM_MAC: self._progress.setAttribute(Qt.WA_MacMiniSize) self._progress.setMaximumHeight(16) progressLayout.addWidget(self._progress, 1) self._button = QPushButton(progressWidget) self._button.clicked.connect(self._buttonClicked) progressLayout.addSpacing(5) progressLayout.addWidget(self._button, 0, Qt.AlignCenter) layout.addWidget(progressWidget, 0, Qt.AlignBottom) self._statusLabel = QLabel(self) if getPlatform() == PLATFORM_MAC: self._statusLabel.setAttribute(Qt.WA_MacSmallSize) layout.addWidget(self._statusLabel) self.setObjectName(u"__transfer_widget") self.setFrameShape(QFrame.StyledPanel) self.setStyleSheet("QFrame#__transfer_widget{border-width: 1px; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-color:palette(mid)}"); self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)
def appliesToConfiguration(cls, _logger): if getPlatform() != PLATFORM_LINUX: return False try: call = ["dpkg", "-s", "lunchinator"] fh = open(os.path.devnull,"w") p = subprocess.Popen(call,stdout=fh, stderr=fh) p.communicate() retCode = p.returncode if retCode == 0: return True except OSError: # dpkg probably does not exists pass try: call = "rpm -qa | grep lunchinator" fh = open(os.path.devnull,"w") p = subprocess.Popen(call,stdout=fh, stderr=fh, shell=True) p.communicate() retCode = p.returncode if retCode == 0: return True except OSError: # dpkg probably does not exists pass return False
def _initUI(self): layout = QVBoxLayout(self) layout.setContentsMargins(0, 10, 0, 0) layout.setSpacing(0) labelLayout = QHBoxLayout() labelLayout.addWidget(QLabel(u"Sorry, something went wrong:", self)) labelLayout.setContentsMargins(10, 0, 0, 0) layout.addLayout(labelLayout) layout.addSpacing(5) self._errorLog = QTextEdit(self) self._errorLog.setReadOnly(True) self._errorLog.setWordWrapMode(QTextOption.NoWrap) self._errorLog.setTextColor(QColor(180, 0, 0)) self._errorLog.setObjectName(u"__ERROR_LOG_") self._errorLog.setFrameShape(QFrame.StyledPanel) if getPlatform() == PLATFORM_MAC: self._errorLog.setStyleSheet("QFrame#__ERROR_LOG_{border-width: 1px; border-top-style: solid; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-color:palette(mid)}"); layout.addWidget(self._errorLog) bottomWidget = QWidget(self) bottomLayout = QHBoxLayout(bottomWidget) self._notAgain = QCheckBox(u"Please, no more error messages!", self) bottomLayout.addWidget(self._notAgain, 1, Qt.AlignTop) buttonBox = QDialogButtonBox(QDialogButtonBox.Close, Qt.Horizontal, self) buttonBox.rejected.connect(self.reject) bottomLayout.addWidget(buttonBox) layout.addWidget(bottomWidget)
def __init__(self, parent, buttonText, triggeredEvent, sortedColumn=None, ascending=True, placeholderText="", useTextEdit=False, sortingEnabled=True): super(TableWidget, self).__init__(parent) self.externalEvent = triggeredEvent # create HBox in VBox for each table # Create message table bottomWidget = QWidget(self) tableBottomLayout = QHBoxLayout(bottomWidget) if getPlatform() == PLATFORM_MAC: tableBottomLayout.setContentsMargins(10, 0, 10, 0) else: tableBottomLayout.setContentsMargins(10, 0, 10, 5) self.table = QTreeView(self) self.table.setSortingEnabled(sortingEnabled) self.table.setHeaderHidden(False) self.table.setAlternatingRowColors(True) self.table.setIndentation(0) self.table.setUniformRowHeights(True) self.table.setObjectName(self._TABLE_OBJ_NAME) self.table.setFrameShape(QFrame.StyledPanel) if getPlatform() == PLATFORM_MAC: self.table.setStyleSheet("QFrame#%s{border-width: 1px; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-color:palette(mid)}" % self._TABLE_OBJ_NAME); if sortedColumn != None: self.table.sortByColumn(sortedColumn, Qt.AscendingOrder if ascending else Qt.DescendingOrder) if useTextEdit: self.entry = HistoryTextEdit(self) else: self.entry = HistoryLineEdit(self, placeholderText) tableBottomLayout.addWidget(self.entry) button = QPushButton(buttonText, self) button.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.MinimumExpanding) tableBottomLayout.addWidget(button, 0, Qt.AlignBottom if useTextEdit else Qt.AlignCenter) tableLayout = QVBoxLayout(self) tableLayout.setSpacing(5) tableLayout.setContentsMargins(0, 0, 0, 0) tableLayout.addWidget(self.table) tableLayout.addWidget(bottomWidget) self.entry.returnPressed.connect(self.eventTriggered) button.clicked.connect(self.eventTriggered) self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)
def run(self): myPlatform = getPlatform() if myPlatform == PLATFORM_LINUX: self._drawAttentionLinux(self._audioFile, self._openTray) elif myPlatform == PLATFORM_MAC: self._drawAttentionMac(self._audioFile, self._openTray) elif myPlatform == PLATFORM_WINDOWS: self._drawAttentionWindows(self._audioFile, self._openTray)
def _installGPG(self, phase=0, dt=None): if getPlatform() == PLATFORM_MAC: # TODO handle errors if phase == 0: self._ui.setInteractive(False) self._setStatus("Searching for latest version...") dt = DownloadThread(getValidQtParent(), self.logger, "https://gpgtools.org/releases/macgpg2/appcast.xml") dt.success.connect(partial(self._install_gpg_finished, 0)) dt.error.connect(partial(self._install_gpg_failed, 0)) dt.start() elif phase == 1: xmlContent = dt.getResult() dt.close() e = ElementTree.fromstring(xmlContent) dmgURL = e.iter("channel").next().iter("item").next().iter("enclosure").next().attrib["url"] tmpFile = tempfile.NamedTemporaryFile(suffix=".dmg", prefix="macgpg", delete=False) self.logger.debug("Downloading %s to %s", dmgURL, tmpFile.name) self._setStatus("Downloading MacGPG...", progress=True) self._ui.setProgress(0) dt = DownloadThread(getValidQtParent(), self.logger, dmgURL, target=tmpFile, progress=True) dt.success.connect(partial(self._install_gpg_finished, 1)) dt.error.connect(partial(self._install_gpg_failed, 1)) dt.progressChanged.connect(self._downloadProgressChanged) dt.start() elif phase == 2: # indeterminate self._ui.setProgressIndeterminate(True) self._setStatus("Installing MacGPG...", progress=True) dmgFile = dt.target.name dt.close() st = ShellThread(getValidQtParent(), self.logger, [get_settings().get_resource('bin', 'mac_gpg_installer.sh'), dmgFile], context=dmgFile, quiet=False) st.finished.connect(partial(self._install_gpg_finished, 2)) st.start() elif phase == 3: dmgFile = dt.context if os.path.exists(dmgFile): os.remove(dmgFile) self._ui.setProgressIndeterminate(False) if dt.exitCode == 0: self._setStatus("MacGPG installed successfully.") else: self._setStatus("Error installing MacGPG.", err=True) if dt.pErr: self.logger.error("Error installing MacGPG.\nConsole output: %s", dt.pErr.strip()) self._updateCheckButtonText() self._ui.setInteractive(True)
def createNotebook(self): self.combobox.setCurrentIndex(0) for _ in range(self.menuNotebook.count()): self.menuNotebook.removeWidget(self.menuNotebook.widget(0)) curMessages = self.messages curAdditives = self.additives for index in range(10): if index == 5: try: if getPlatform() != PLATFORM_WINDOWS: locale.setlocale(locale.LC_TIME, (self.messages["toggleLocale"],"UTF-8")) except: log_exception("error setting locale") curMessages = self.toggleMessages curAdditives = self.toggleAdditives pageWidget = QWidget(self.menuNotebook) page = QVBoxLayout(pageWidget) thisLunchMenu = LunchMenu.allLunchMenus()[index] if thisLunchMenu != None and type(thisLunchMenu) == LunchMenu: title = curMessages['lunchMenuFor'] + u" " + thisLunchMenu.lunchDate.strftime(curMessages['dateFormatDisplayed']).decode("utf-8") self.addMenuLine(pageWidget, title, page, True) if thisLunchMenu.isValid(): self.addMenuContent(pageWidget, curMessages['soupDisplayed'], thisLunchMenu.contents, page, curMessages, curAdditives) self.addMenuContent(pageWidget, curMessages['mainDishesDisplayed'], thisLunchMenu.contents, page, curMessages, curAdditives) self.addMenuContent(pageWidget, curMessages['supplementsDisplayed'], thisLunchMenu.contents, page, curMessages, curAdditives) self.addMenuContent(pageWidget, curMessages['dessertsDisplayed'], thisLunchMenu.contents, page, curMessages, curAdditives) else: self.addMenuLine(pageWidget, curMessages['noLunchToday'], page) elif type(thisLunchMenu) == locale.Error: self.addLocaleErrorPage(pageWidget, page, index >= 5) pass elif isinstance(thisLunchMenu, Exception): self.addExceptionPage(pageWidget, page, thisLunchMenu, index >= 5) self.menuNotebook.addWidget(pageWidget) try: if getPlatform() != PLATFORM_WINDOWS: locale.setlocale(locale.LC_TIME, (LunchMenu.defaultLocaleString,"UTF-8")) except: log_exception("error setting locale") self.goToday()
def _getMD(self): if self._md is None: try: from markdown import Markdown if getPlatform()==PLATFORM_WINDOWS and isPyinstallerBuild(): self._md = Markdown() else: self._md = Markdown(extensions=['extra']) except ImportError: self.logger.error("Cannot enable Markdown (%s)", formatException()) raise return self._md
def _initPeerList(self): self._peerList = QTreeView(self) self._peerList.setAlternatingRowColors(True) self._peerList.setHeaderHidden(False) self._peerList.setItemsExpandable(False) self._peerList.setIndentation(0) self._peerList.setModel(self._peerModel) self._peerList.setSelectionMode(QTreeView.SingleSelection) self._peerList.selectionModel().selectionChanged.connect(self._displayHistory) self._peerList.setObjectName(u"__peer_list") self._peerList.setFrameShape(QFrame.StyledPanel) if getPlatform() == PLATFORM_MAC: self._peerList.setStyleSheet("QFrame#__peer_list{border-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: none; border-left-style: none; border-color:palette(mid)}");
def __init__(self, parent, logger): super(HistoryTable, self).__init__(parent) self.logger = logger self.setAlternatingRowColors(False) self.setHeaderHidden(False) self.setItemsExpandable(False) self.setIndentation(0) self.setItemDelegate(MessageItemDelegate(self, logger, column=2, margin=0)) self.setSelectionMode(QTreeView.NoSelection) self.setObjectName(u"__peer_list") self.setFrameShape(QFrame.StyledPanel) if getPlatform() == PLATFORM_MAC: self.setStyleSheet("QFrame#__peer_list{border-width: 1px; border-top-style: solid; border-right-style: none; border-bottom-style: none; border-left-style: solid; border-color:palette(mid)}");
def _highlightIcon(self): if self._highlightNewMessage: name = "lunchinatorred" elif self._highlightPeersReady: name = "lunchinatorgreen" else: name = "lunchinator" icon_file = get_settings().get_resource("images", name + (".png" if getPlatform() == PLATFORM_WINDOWS else ".svg")) icon = None if hasattr(QIcon, "fromTheme"): icon = QIcon.fromTheme(name, QIcon(icon_file)) if not icon: icon = QIcon(icon_file) self.statusicon.setIcon(icon)
def _initUI(self, text): layout = QVBoxLayout(self) layout.setContentsMargins(0, 10, 0, 0) layout.setSpacing(5) labelLayout = QHBoxLayout() if not text: text = u"Some plugins cannot be activated due to missing requirements:" label = QLabel(text, self) label.setWordWrap(True) labelLayout.addWidget(label) labelLayout.setContentsMargins(10, 0, 0, 0) layout.addLayout(labelLayout) self._reqTable = QTreeWidget(self) self._reqTable.setSortingEnabled(False) self._reqTable.setHeaderHidden(False) self._reqTable.setAlternatingRowColors(True) self._reqTable.setIndentation(0) self._reqTable.setUniformRowHeights(True) self._reqTable.setObjectName(u"__ERROR_LOG_") self._reqTable.setColumnCount(3) self._reqTable.setHeaderLabels([u"Package", u"Problem", u"Required by"]) self._reqTable.setFrameShape(QFrame.StyledPanel) if getPlatform() == PLATFORM_MAC: self._reqTable.setAttribute(Qt.WA_MacShowFocusRect, False) self._reqTable.setStyleSheet("QFrame#__ERROR_LOG_{border-width: 1px; border-top-style: solid; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-color:palette(mid)}"); layout.addWidget(self._reqTable) buttonBox = QDialogButtonBox(Qt.Horizontal, self) ignore = QPushButton(u"Ignore", self) deactivate = QPushButton(u"Deactivate", self) install = QPushButton(u"Install Selected", self) install.setEnabled(self._canInstall) buttonBox.addButton(deactivate, QDialogButtonBox.DestructiveRole) buttonBox.addButton(ignore, QDialogButtonBox.RejectRole) buttonBox.addButton(install, QDialogButtonBox.AcceptRole) deactivate.clicked.connect(self._deactivate) ignore.clicked.connect(self._ignore) buttonBox.accepted.connect(self.accept) bottomLayout = QHBoxLayout() bottomLayout.addWidget(buttonBox, 1, Qt.AlignRight) layout.addLayout(bottomLayout)
def _initCentralView(self): self._transferList = DeleteKeyTreeWidget(self) self._transferList.setObjectName(u"__transfer_list") self._transferList.setFrameShape(QFrame.StyledPanel) if getPlatform() == PLATFORM_MAC: if self._asWindow: self._transferList.setAttribute(Qt.WA_MacShowFocusRect, False) self._transferList.setStyleSheet("QFrame#__transfer_list{border-width: 1px; border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-color:palette(mid)}"); else: self._transferList.setStyleSheet("QFrame#__transfer_list{border-width: 1px; border-top-style: solid; border-right-style: none; border-bottom-style: none; border-left-style: none; border-color:palette(mid)}"); self._transferList.setColumnCount(1) self._transferList.setAlternatingRowColors(False) self._transferList.setHeaderHidden(True) self._transferList.setItemsExpandable(False) self._transferList.setIndentation(0) self._transferList.setSelectionMode(QTreeWidget.SingleSelection) self._transferList.itemDoubleClicked.connect(self._itemDoubleClicked) self._transferList.deletePressed.connect(self._deletePressed) self._transferList.setVerticalScrollMode(QTreeWidget.ScrollPerPixel) return self._transferList
def createNotebook(self): self.combobox.setCurrentIndex(0) for _ in range(self.menuNotebook.count()): self.menuNotebook.removeWidget(self.menuNotebook.widget(0)) curMessages = self.messages curAdditives = self.additives for index in range(10): if index == 5: try: if getPlatform() != PLATFORM_WINDOWS: locale.setlocale( locale.LC_TIME, (self.messages["toggleLocale"], "UTF-8")) except: log_exception("error setting locale") curMessages = self.toggleMessages curAdditives = self.toggleAdditives pageWidget = QWidget(self.menuNotebook) page = QVBoxLayout(pageWidget) thisLunchMenu = LunchMenu.allLunchMenus()[index] if thisLunchMenu != None and type(thisLunchMenu) == LunchMenu: title = curMessages[ 'lunchMenuFor'] + u" " + thisLunchMenu.lunchDate.strftime( curMessages['dateFormatDisplayed']).decode("utf-8") self.addMenuLine(pageWidget, title, page, True) if thisLunchMenu.isValid(): self.addMenuContent(pageWidget, curMessages['soupDisplayed'], thisLunchMenu.contents, page, curMessages, curAdditives) self.addMenuContent(pageWidget, curMessages['mainDishesDisplayed'], thisLunchMenu.contents, page, curMessages, curAdditives) self.addMenuContent(pageWidget, curMessages['supplementsDisplayed'], thisLunchMenu.contents, page, curMessages, curAdditives) self.addMenuContent(pageWidget, curMessages['dessertsDisplayed'], thisLunchMenu.contents, page, curMessages, curAdditives) else: self.addMenuLine(pageWidget, curMessages['noLunchToday'], page) elif type(thisLunchMenu) == locale.Error: self.addLocaleErrorPage(pageWidget, page, index >= 5) pass elif isinstance(thisLunchMenu, Exception): self.addExceptionPage(pageWidget, page, thisLunchMenu, index >= 5) self.menuNotebook.addWidget(pageWidget) try: if getPlatform() != PLATFORM_WINDOWS: locale.setlocale(locale.LC_TIME, (LunchMenu.defaultLocaleString, "UTF-8")) except: log_exception("error setting locale") self.goToday()
gbinary = getBinary("gpg", "bin") if not gbinary: getCoreLogger().error("GPG not found") sys.exit(1) ghome = os.path.join(get_settings().get_main_config_dir(),"gnupg") if not locale.getpreferredencoding(): os.putenv("LANG", "en_US.UTF-8") if not locale.getpreferredencoding(): os.putenv("LANG", "en_US.UTF-8") try: gpg = None if getPlatform() == PLATFORM_WINDOWS: gpg = GPG("\""+gbinary+"\"",ghome) else: gpg = GPG(gbinary,ghome) if not gpg.encoding: gpg.encoding = 'utf-8' except Exception, e: getCoreLogger().exception("GPG not working: "+str(e)) sys.exit(1) db_file = os.path.join(get_settings().get_main_config_dir(),"lunchinator.sq3") tries = 10 public_key = "0x17F57DC2" cnx = sqlite3.connect(db_file) cursor = cnx.cursor()
def appliesToConfiguration(cls, _logger): return lunchinator_has_gui() and getPlatform() == PLATFORM_WINDOWS
def startLunchinator(): (options, _args) = parse_args() # @todo: using the variable "usePlugins" this way is confusing - refactor later usePlugins = options.noPlugins if options.output: options.cli = False options.noGui = True usePlugins = True # <- means do NOT use plugins defaultLogPath = os.path.join(MAIN_CONFIG_DIR, "lunchinator.log") if options.exitWithStopCode: sys.exit(EXIT_CODE_STOP) elif options.version: initLogger(options) print "Lunchinator", get_settings().get_version() sys.exit(0) elif options.lunchCall or options.message != None: initLogger(options) get_settings().set_plugins_enabled(False) sendMessage(options.message, options.client) elif options.input: initLogger(options) get_settings().set_plugins_enabled(False) msg = sys.stdin.read() # @todo options.client if msg: sendMessage("HELO_LOCAL_PIPE " + msg, "127.0.0.1") elif options.stop: initLogger(options) get_settings().set_plugins_enabled(False) get_server().stop_server(stop_any=True) print "Sent stop command to local lunchinator" elif options.installDep: initLogger(options) req = getCoreDependencies() installDependencies(req) # lunchinator starts in listening mode: elif options.cli: initLogger(options, defaultLogPath) usePlugins = checkDependencies(usePlugins) retCode = 1 try: from lunchinator import lunch_cli get_settings().set_plugins_enabled(usePlugins) get_server().set_disable_broadcast(options.noBroadcast) cli = lunch_cli.LunchCommandLineInterface() sys.retCode = cli.start() except: getCoreLogger().exception("cli version cannot be started") finally: sys.exit(retCode) elif options.noGui: initLogger(options, defaultLogPath) usePlugins = checkDependencies(usePlugins) # sys.settrace(trace) get_settings().set_plugins_enabled(usePlugins) get_server().set_disable_broadcast(options.noBroadcast) get_server().initialize() get_server().start_server() sys.exit(get_server().exitCode) else: signal.signal(signal.SIGINT, signal.SIG_IGN) if getPlatform() != PLATFORM_MAC: import socket try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.bind(("", 50000)) s.close() except: # something is listening, hopefully a lunchinator print "The lunchinator port is already in use, trying to open window" initLogger(options) sendMessage("HELO_OPEN_WINDOW please", "127.0.0.1") sys.exit(0) initLogger(options, defaultLogPath) getCoreLogger().info("We are on %s, %s, version %s", platform.system(), platform.release(), platform.version()) try: from PyQt4.QtCore import QThread set_has_gui(True) except: getCoreLogger().error("pyQT4 not found - start lunchinator with --no-gui") sys.exit(EXIT_CODE_NO_QT) from lunchinator.gui_controller import LunchinatorGuiController from PyQt4.QtGui import QApplication class LunchApplication(QApplication): def notify(self, obj, event): try: return QApplication.notify(self, obj, event) except: getCoreLogger().exception("C++ Error") return False app = LunchApplication(sys.argv) usePlugins = checkDependencies(usePlugins) get_settings().set_plugins_enabled(usePlugins) get_server().set_disable_broadcast(options.noBroadcast) app.setQuitOnLastWindowClosed(False) lanschi = LunchinatorGuiController() if lanschi.isShuttingDown(): # seems lanschi would prefer to not start up sys.exit(0) if options.showWindow: lanschi.openWindowClicked() if getPlatform() == PLATFORM_MAC and isPyinstallerBuild(): import AppKit class MyDelegate(AppKit.AppKit.NSObject): def applicationShouldHandleReopen_hasVisibleWindows_(self, _app, hasOpenWindow): if not hasOpenWindow: lanschi.openWindowClicked() delegate = MyDelegate.alloc().init() AppKit.AppKit.NSApplication.sharedApplication().setDelegate_(delegate) # enable CRTL-C signal.signal(signal.SIGINT, partial(handleInterrupt, lanschi)) try: app.exec_() finally: retValue = lanschi.quit() sys.exit(retValue)
def trayActivated(self, reason): if getPlatform() == PLATFORM_MAC: # Trigger is sent even though the context menu is shown. return if reason == QSystemTrayIcon.Trigger: self.statusicon.contextMenu().popup(QCursor.pos())
from functools import partial from lunchinator import get_server, utilities, lunchinator_has_gui,\ get_notification_center, get_settings, get_plugin_manager from lunchinator.log import loggingFunc from lunchinator.lunch_server_controller import LunchServerController from lunchinator.cli.cli_message import CLIMessageHandling from lunchinator.cli.cli_option import CLIOptionHandling from lunchinator.cli.cli_plugin import CLIPluginHandling from lunchinator.cli.cli_privacy import CLIPrivacyHandling from lunchinator.lunch_server import EXIT_CODE_UPDATE from lunchinator.log.lunch_logger import newLogger from lunchinator.cli.cli_logging import CLILoggingHandling # enable tab completion on most platforms if utilities.getPlatform() != utilities.PLATFORM_WINDOWS: import readline import rlcompleter if 'libedit' in readline.__doc__: readline.parse_and_bind("bind ^I rl_complete") else: readline.parse_and_bind("tab: complete") class ServerThread(threading.Thread): def run(self): try: get_server().start_server() except: from lunchinator.log import getCoreLogger getCoreLogger().exception("Exception in Lunch Server")
def appliesToConfiguration(cls, _logger): return lunchinator_has_gui() and getPlatform() == PLATFORM_MAC and getApplicationBundle() != None