Beispiel #1
0
 def about(self, sender):
     #rumps.alert("My quit message")
     if self.apiServer:
         self.apiServer.shutdown()
     AppHelper.stopEventLoop()
     rumps.quit_application()
     sys.exit()
Beispiel #2
0
 def clean_quit(self):
     daemon = xmlrpclib.ServerProxy("http://localhost:7080/")
     try:
         daemon.stop()
     except:
         pass
     rumps.quit_application()
Beispiel #3
0
    def handle_missing_apikey(self):
        ''' Open window to alert user of missing api key '''

        self.logger.info('Opening \'API Key is required\' window')

        response = rumps.alert(
            title='ClimaCell API Key is required',
            message=(
                'Click \"Register\" or go to the following url:\n'
                f'{self.climacell.signup_link}\n\n'
                'Note: This application is not affiliated with ClimaCell'),
            ok='Register',
            cancel='Quit',
            other='I have one')

        if response == 0:  # Quit
            self.logger.info('Quiting application')
            rumps.quit_application()

        if response == 1:  # Register
            self.logger.info('Opening register link')
            webbrowser.open(self.climacell.signup_link)

        if not self.set_apikey():  # Cancelled enter api key window
            self.handle_missing_apikey()  # Reopen api required alert
Beispiel #4
0
 def about(self, sender):
     #rumps.alert("My quit message")
     if self.apiServer:
         self.apiServer.shutdown()
     AppHelper.stopEventLoop()
     rumps.quit_application()
     sys.exit()
Beispiel #5
0
 def remove_me(self):
     self.reset()
     app = self.get_app()
     if app != "":
         os.system('rm -rf "%s"' % app)
     else:
         print('%s is not in App' % self.get_exe())
     rumps.quit_application()
Beispiel #6
0
 def menu_quit(self, _):
     try:
         self.console.set_exit()
         self.vicki.player.shutdown()
         self.th.stop_all()
     except Exception as exc:
         logger.error(repr(exc))
     rumps.quit_application()
Beispiel #7
0
 def menu_quit(self, _):
     try:
         self.console.set_exit()
         self.vicki.player.shutdown()
         self.th.stop_all()
     except Exception as exc:
         logger.error(repr(exc))
     rumps.quit_application()
Beispiel #8
0
 def quit(self, menuItem=None):
     try:
         log.log("Quit - Ran for %d seconds" % int(time.time() - self.start))
         suspender.exit()
         if self.quit_callback:
             self.quit_callback()
     except:
         error.error("Could not quit")
     finally:
         rumps.quit_application()
 def exit(self, _):
     # rumps.notification("Awesome title", "amazing subtitle", "hi!!1")
     payload = {
         "content": 'stop',
         "node_id": "all",
         "node_name": "_"
     }  # todo message template
     # 变量的可见性 :),坏习惯
     Node.publish_payload(payload, NODES_OPERATE_TOPIC)  # 发送给
     time.sleep(0.2)
     rumps.quit_application()
Beispiel #10
0
 def run(self):
     profiler.setprofile(self)
     while True:
         time.sleep(self.interval)
         try:
             self.callback.run()
         except psutil.NoSuchProcess:
             pass  # this is normal
         except Exception as e:
             error.error("Error in Timer callback '%s': %s" %
                         (self.callback.callback.im_func.__name__, e))
             rumps.quit_application()
Beispiel #11
0
    def disconnect_vpn(self, _):
        self.lock.acquire()
        time.sleep(self.sleep_time + 0.5)

        ret, out = commands.getstatusoutput(
            '/opt/cisco/anyconnect/bin/vpn disconnect')
        if ret != 0:
            self.logger.fatal(
                "Error disconnecting VPN: error: {0}".format(out))
        else:
            self.lock.release()
            self.notify(self.notification_title, "VPN disconnected")
        rumps.quit_application()
Beispiel #12
0
def measure_time(_):
    timer_now = time.time()
    remaining_time = int(minutes - (timer_now - start))
    timer_minutes = str((remaining_time) // 60)
    timer_second = str((remaining_time) % 60)
    if int(timer_second) < 10:
        timer_second = '0' + timer_second

    if (remaining_time) > 0:
        app.title = '残り時間:' + timer_minutes + ':' + timer_second
    elif (remaining_time) <= 0:
        app.title = 'TIMEUP'
        rumps.alert(message='時間になりました!')
        rumps.quit_application()
Beispiel #13
0
    def setMenu(self, connected=True):
        self.prevItem = rumps.MenuItem(
            "Previous", callback=lambda _: self.device.previous())
        self.playPauseItem = rumps.MenuItem(
            "Play", callback=lambda _: self.__onPlayPauseClicked())
        self.nextItem = rumps.MenuItem("Next",
                                       callback=lambda _: self.device.next())

        self.volumeDescItem = rumps.MenuItem(
            "Volume", callback=lambda _: self.__onMuteClicked())
        self.volumeItem = rumps.SliderMenuItem(
            value=0,
            min_value=0,
            max_value=100,
            callback=lambda item: self.__onVolumeChanged(item.value))

        self.preferencesItem = rumps.MenuItem("Preferences")
        self.deviceSelectedItem = rumps.MenuItem(f"Device: {self.deviceName}")
        self.textShownItem = rumps.MenuItem(
            "Show Artist > Title in Menu Bar",
            callback=lambda _: self.__onTextShownChanged())
        self.textShownItem.state = int(self.config["TEXT_SHOWN"])
        # self.deviceSelectedItem = rumps.MenuItem(f"Device: {self.deviceName}", callback=lambda _ : self.__onDeviceSelectedClicked())
        for cc in self.chromecasts:
            name = cc.device.friendly_name
            self.deviceSelectedItem.add(
                rumps.MenuItem(name, callback=self.__onDeviceSelected))
        self.preferencesItem.add(self.deviceSelectedItem)
        self.preferencesItem.add(self.textShownItem)
        self.preferencesItem.add(None)
        for key in [
                "PREV_KEY", "PLAY_KEY", "NEXT_KEY", "MUTE_KEY", "VOLD_KEY",
                "VOLU_KEY"
        ]:
            self.preferencesItem.add(
                rumps.MenuItem(f"{KEY_NAMES[key]}: {self.config[key]}",
                               callback=self.__onKeyClicked))
        self.preferencesItem.add(None)
        self.reattachKeysItem = rumps.MenuItem(
            "Reload conf", callback=lambda _: self.__init__())
        self.preferencesItem.add(self.reattachKeysItem)

        self.aboutItem = rumps.MenuItem(
            "About",
            callback=lambda item: os.system(
                "open \"\" https://pierrejacquier.com/castmenu"))
        self.quitItem = rumps.MenuItem(
            "Quit", callback=lambda item: rumps.quit_application())

        self.menu.clear()
        self.menu = [
            self.prevItem, self.playPauseItem, self.nextItem, None,
            self.volumeDescItem, self.volumeItem, None, self.preferencesItem,
            self.aboutItem, self.quitItem
        ]
Beispiel #14
0
    def __init__(self):
        super(RTNotifier, self).__init__("RT Notifier", icon='57365.png')
        self.config = None

        # Set user/password/url, either by asking or by getting from the config
        xdg_base = xdg.BaseDirectory.load_first_config(self.__class__.__name__)
        config_path = os.path.join(xdg_base, RTNotifier.CONFIG_NAME) if xdg_base else ''

        self.config = SafeConfigParser()
        if os.path.isfile(config_path):
            # Load config file
            with open(config_path) as f:
                self.config.readfp(f)
        else:
            self.config.add_section('main')
            if self.set_user_pass(None) and self.set_url(None) and self.set_renotify_time(None):
                self.save_config()
            else:
                rumps.quit_application()

        renotify_time = self.config.getint('main', 'renotify_time') * 60
        self.tickets = expiringdict.ExpiringDict(max_len=100, max_age_seconds=renotify_time)
        self.debug = False
        rumps.debug_mode(self.debug)
Beispiel #15
0
 def quit(self, sender):
     if self.apiServer:
         self.apiServer.kill()
     AppHelper.stopEventLoop()
     rumps.quit_application()
     sys.exit()
Beispiel #16
0
 def shutdown(self):
     rumps.quit_application()
Beispiel #17
0
 def quit(self, a):
     os.system("killall afplay")
     rumps.quit_application()
Beispiel #18
0
 def quit(_):
     rumps.quit_application()
Beispiel #19
0
    def quit(self, sender):

        self.application.terminate()
        rumps.quit_application(self)
 def quit(self, _):
     tray_common.stop_app()
     self.status_checker.stop()
     rumps.quit_application()
Beispiel #21
0
 def quit(self, sender):
     if self.apiServer:
         self.apiServer.kill()
     AppHelper.stopEventLoop()
     rumps.quit_application()
     sys.exit()
Beispiel #22
0
 def quit_app(self, _):
     try:
         self.service.stop()
     except:
         pass
     rumps.quit_application()
Beispiel #23
0
 def clean_quit_application(self, _):
     self.ap_handler.shut_down()
     rumps.quit_application()
Beispiel #24
0
 def on_quit(self, _):
     module_init.stop_all()
     rumps.quit_application()
Beispiel #25
0
def clean_up_before_quit(_):
    QRD_process.terminate()
    rumps.quit_application()
Beispiel #26
0
 def __updateMenu(self):
     menuItems = list(map(lambda container: container.getMenuItem(), self.__containers.values()))
     menuItems.append(None) # separator
     menuItems.append(rumps.MenuItem("Quit Docker Menu", lambda _: rumps.quit_application(_)))
     self.menu.clear()
     self.menu = menuItems
Beispiel #27
0
	def quit(self, _):
		self.manager.shutdown_tunnels()
		rumps.quit_application()
Beispiel #28
0
 def quit(self):
     rumps.quit_application()
Beispiel #29
0
 def quit_app(self, sender):
     self.dump_clocks_data()
     self.dump_intvl_data()
     quit_application(sender)
Beispiel #30
0
 def quit_app(self, _):
     if self.started == True:
         self.p1.terminate()
         self.p1.join()
     rumps.quit_application()
 def quit(self, _):
     tray_common.stop_app()
     rumps.quit_application()
Beispiel #32
0
 def quit(self, sender):
     if isinstance(self.caffeine_proc, subprocess.Popen):
         self.caffeine_proc.kill()
     rumps.quit_application(sender)
Beispiel #33
0
def save_config_and_quit(_):
    config_save()
    rumps.quit_application()
Beispiel #34
0
def clean_up_before_quit(_):
    print('execute clean up code')
    rumps.quit_application()
Beispiel #35
0
 def quit(self, _):
     tray_common.stop_app()
     rumps.quit_application()
Beispiel #36
0
 def quit(self, _):
     global_mode_off()
     pac_mode_off()
     stop_pac_server()
     stop_trojan()
     rumps.quit_application()
Beispiel #37
0
def get_input():
    try:        
        while True:
            line = sys.stdin.readline()
            if not line:
                break

            if line == '':
                continue

            print "info:Read %s" % line
            sys.stdout.flush()
            cfg = None
            try:
                cfg = json.loads(line)
            except:
                pass

            if cfg == None:
                print "info:Unable to parse line"
                sys.stdout.flush()
                continue

            if cfg.has_key("Action"):
                print "info:Running %s" % cfg["Action"]
                sys.stdout.flush()

                if cfg["Action"] == "setmenu":
                    menu = cfg["Menu"]

                    if lookup.has_key(menu["Key"]):
                        lookup[menu["Key"]].title = menu["Text"]

                        if menu.has_key("Enabled") and not menu["Enabled"]:
                            lookup[menu["Key"]].set_callback(None)
                        else:
                            lookup[menu["Key"]].set_callback(item_clicked)
                        app.menu.update([])
                    else:
                        print "warn:Key not found %s" % cfg["Action"]
                        sys.stdout.flush()



                elif cfg["Action"] == "setmenus":
                    app.menu.clear()
                    app.menu = parsemenus(cfg)
                    print "info:Updated menus"
                    sys.stdout.flush()
                elif cfg["Action"] == "seticon":

                    try:
                        raw = base64.b64decode(cfg["Image"])
                        data = NSData.dataWithBytes_length_(raw, len(raw))
                        img = NSImage.alloc().initWithData_(data)    
                        img.setScalesWhenResized_(True)
                        img.setSize_((21, 21))
                        app.icon = img

                        print "info:Image updated"
                        sys.stdout.flush()

                    except:
                        print "warn:Failed to set image"
                        sys.stdout.flush()

                elif cfg["Action"] == "shutdown":
                    break
                elif cfg["Action"] == "notification":
                    if rumps_NOTIFICATIONS:
                        rumps.notification(cfg["Title"], '', cfg["Message"])

    finally:
        rumps.quit_application()     
        print "info:Shutdown"
        sys.stdout.flush()

    print "info:Stdin close"
    sys.stdout.flush()
    sys.stdin.close()
Beispiel #38
0
 def quit(self, _):
     logging.info("stop (program end)")
     rumps.quit_application()
Beispiel #39
0
 def on_quit(self, _):
     rumps.quit_application()
Beispiel #40
0
 def quit(self, _):
     self.save_setted()
     rumps.quit_application()
Beispiel #41
0
 def quit(self, _):
     rumps.quit_application(sender=None)
Beispiel #42
0
def get_input():
    try:        
        while True:
            line = sys.stdin.readline()
            if not line:
                break

            if line == '':
                continue

            print "info:Read %s" % line
            sys.stdout.flush()
            cfg = None
            try:
                cfg = json.loads(line)
            except:
                pass

            if cfg == None:
                print "info:Unable to parse line"
                sys.stdout.flush()
                continue

            if cfg.has_key("Action"):
                print "info:Running %s" % cfg["Action"]
                sys.stdout.flush()

                if cfg["Action"] == "setmenu":
                    menu = cfg["Menu"]

                    if lookup.has_key(menu["Key"]):
                        lookup[menu["Key"]].title = menu["Text"]

                        if menu.has_key("Enabled") and not menu["Enabled"]:
                            lookup[menu["Key"]].set_callback(None)
                        else:
                            lookup[menu["Key"]].set_callback(item_clicked)
                        app.menu.update([])
                    else:
                        print "warn:Key not found %s" % cfg["Action"]
                        sys.stdout.flush()



                elif cfg["Action"] == "setmenus":
                    app.menu.clear()
                    app.menu = parsemenus(cfg)
                    print "info:Updated menus"
                    sys.stdout.flush()
                elif cfg["Action"] == "seticon":

                    try:
                        raw = base64.b64decode(cfg["Image"])
                        data = NSData.dataWithBytes_length_(raw, len(raw))
                        img = NSImage.alloc().initWithData_(data)    
                        img.setScalesWhenResized_(True)
                        img.setSize_((18, 18))
                        img.setTemplate_(True)
                        app.icon = img

                        print "info:Image updated"
                        sys.stdout.flush()

                    except:
                        print "warn:Failed to set image"
                        sys.stdout.flush()

                elif cfg["Action"] == "setappicon":

                    try:
                        raw = base64.b64decode(cfg["Image"])
                        data = NSData.dataWithBytes_length_(raw, len(raw))
                        img = NSImage.alloc().initWithData_(data)    
                        #img.setScalesWhenResized_(True)
                        #img.setSize_((21, 21))
                        NSApplication.sharedApplication().setApplicationIconImage_(img)

                        print "info:AppImage updated"
                        sys.stdout.flush()

                    except:
                        print "warn:Failed to set image"
                        sys.stdout.flush()

                elif cfg["Action"] == "shutdown":
                    break

                elif cfg["Action"] == "foreground":
                    transform_app_type(True)
                elif cfg["Action"] == "background":
                    transform_app_type(False)

                elif cfg["Action"] == "notification":
                    if rumps._NOTIFICATIONS:
                        title = cfg["Title"]
                        message = cfg["Message"]
                        subtitle = ''
                        playSound = True
                        image = None

                        if cfg.has_key("SubTitle"):
                            subtitle = cfg["SubTitle"]

                        if cfg.has_key("PlaySound"):
                            playSound = cfg["PlaySound"]
                        if cfg.has_key("Image"):
                            try:
                                raw = base64.b64decode(cfg["Image"])
                                data = NSData.dataWithBytes_length_(raw, len(raw))
                                image = NSImage.alloc().initWithData_(data)
                            except:
                                print "warn:Failed to decode image"
                                sys.stdout.flush()

                        rumps.notification(cfg["Title"], subtitle, cfg["Message"], sound=playSound, image=image)

    finally:
        try:
            traceback.print_exc()
        except:
            pass

        rumps.quit_application()     
        print "info:Shutdown"
        sys.stdout.flush()

    print "info:Stdin close"
    sys.stdout.flush()
    sys.stdin.close()
Beispiel #43
0
 def quit(self, sender):
     for t in self.threads:
         t.stop()
     rumps.quit_application(sender)
Beispiel #44
0
 def run(self):
     try:
         self.pyobjc_performSelectorOnMainThread_withObject_("run_:", None)
     except Exception as e:
         print(e)
         rumps.quit_application()
Beispiel #45
0
 def clean_up_before_quit(self, _):
     with open(FILE_NAME_STATUS, "w") as file:
         file.write(str(self.__isHidden))
     rumps.quit_application()
def clean_up_before_quit(_):
    print('execute clean up code')
    rumps.quit_application()
Beispiel #47
0
 def quit(self, _):
     self.coordinator.IPC_quit()
     rumps.quit_application()
     
     
Beispiel #48
0
 def quit(self, sender):
     print 'Quit', sender
     if self.watch_timer and self.watch_timer.is_alive():
         self.watch_timer.stop()
     rumps.quit_application()
Beispiel #49
0
def _signal_handler(signal, frame):
    rumps.quit_application()