def main(): app_name = "Computer Time" log_path = os.path.join(rumps.application_support(app_name), LOG_FILE) logging.basicConfig(filename=log_path, level=logging.DEBUG, format="%(asctime)s %(levelname)s %(message)s") ComputerTimeApp(app_name, icon="data/icon000.pdf", template=True).run()
def load_intvl_data(self): filepath = application_support(APP_NAME) + '/' + SUPPORT_INTVL_FILENAME if os.path.exists(filepath): f = open(filepath, 'r') intvl = pickle.load(f) self.clocks.set_times_to_flip(intvl) for s, i in INTVLS_MAP.items(): self.interval_menu[s].state = 1 if i == intvl else 0
def __init__(self, app_name): self.config_path = os.path.join(rumps.application_support(app_name), self.FILENAME) self.config = ConfigParser() self.config.read([self.config_path]) if not self.config.has_section(self.SECTION): self.config.add_section(self.SECTION) if not self.config.has_option(self.SECTION, self.HOST): self.set_host('')
def main(): app_name = "Multi Breaks" log_path = os.path.join(rumps.application_support(app_name), LOG_FILE) logging.basicConfig( filename=log_path, level=logging.DEBUG, format="%(asctime)s %(levelname)s %(message)s", ) MultiBreaksApp(app_name, icon="data/timer.pdf", template=True).run()
def __init__(self, app_name): self.config_path = os.path.join(rumps.application_support(app_name), self.FILENAME) self.config = ConfigParser() self.config.read([self.config_path]) if not self.config.has_section(self.SECTION): self.config.add_section(self.SECTION) if not self.config.has_option(self.SECTION, self.HOST): self.set_host('') if not self.config.has_option(self.SECTION, self.USE_MMOL): self.set_use_mmol(False)
def __getitem__(self, item): '''Returns path to an item in the Application Support folder. Returns the full path to the specified item in the MultiTooner application's Application Support folder. Args: item (str): The name of the file. ''' return os.path.join(rumps.application_support("MultiTooner"), item)
def load_clocks_data(self): clocks_tz = [] filepath = application_support(APP_NAME) + '/' + SUPPORT_CLOCKS_FILENAME if os.path.exists(filepath): f = open(filepath, 'r') for e in pickle.load(f): if isinstance(e, str): clocks_tz.append(e) if len(clocks_tz) > 0: for tz in clocks_tz: self.add_clock(tz) else: self.add_local_clock() return
def update_title(self,_): track = self.zone.group.coordinator.get_current_track_info() title = "%s: %s" % (track['artist'], track['title']) album = track['album'] uri = track['album_art'] if not (self.title and self.title == title): self.title = None self.title = title if uri and not self.uri == title: self.uri = uri filename = os.path.join(rumps.application_support(self.name), 'track.jpeg') urlretrieve (uri, filename) if self.menu['Album info']: self.menu['Album info'].clear() art = MenuItem(album, icon=filename, dimensions=[256, 256], callback=lambda x: None) self.menu['Album info'].update(art) self.menu['Mute'].state = 1 if self.zone.mute else 0
def main(): # Read the configuration file config_file = os.path.join(rumps.application_support(APP_TITLE), 'config.yaml') with open(config_file, 'r') as conf: try: config = yaml.safe_load(conf) except yaml.YAMLError as exc: print(exc) return # Setup our CTRL+C signal handler signal.signal(signal.SIGINT, _signal_handler) # Enable debug mode rumps.debug_mode(config['debug']) # Startup application SlackStatusBarApp(config).run()
def __init__(self, *args, **kwargs): '''Please see help(Applicatioon) for more info.''' # Initialize the application and set the icon super().__init__(*args, **kwargs) self.icon = self._get_resource('icon-desaturated.icns') # Get the application support directory of the toontown engine self._toontown = rumps.application_support('Toontown Rewritten') # Initialize the configuration file and menu self.config = config.Configuration(self, 'config.ini') self.initialize_menu() # Initialize the invasion tracker and start if necessary self._interval = self.config.get_setting('interval') self._invasion_timer = rumps.Timer(self._get_invasions, self._interval) self._tracker = tooner.InvasionTracker() self._invasions = {} if self._track_option.state: self._invasion_timer.start()
def get_path_for_file_config() -> Path: return Path(application_support(APP_NAME)).joinpath("config.json")
import urllib import os.path import subprocess import webbrowser from datetime import datetime import rumps from bin.phrase import load, phrase from bin.utils import lazypath, data_dump, init_browser words = load() rumps.debug_mode(True) ICONFILE = lazypath('static', 'icon.png') HTMLDIR = lazypath('static') SETTINGS_DIR = rumps.application_support('These Days') DATAFILE = os.path.join(SETTINGS_DIR, 'data.json') BROWSERFILE = os.path.join(SETTINGS_DIR, 'index.html') class TheseDaysApp(rumps.App): def __init__(self): super(TheseDaysApp, self).__init__("These Days", title=None, icon=ICONFILE) self.menu = ["These days...", "View history", rumps.separator, "Auto-ask?", "Preferences"] self.browser_url = BROWSERFILE self.settings_dir = SETTINGS_DIR self.datafile = DATAFILE init_browser(HTMLDIR, SETTINGS_DIR) self.PORT = 1988 # @rumps.clicked("Preferences") # def prefs(self, _):
def settings_path(self): if self._settings_path_override is None: return os.path.join(rumps.application_support(self.app_name), self.SETTINGS_FILE_NAME) else: return self._settings_path_override
def dump_intvl_data(self): filepath = application_support(APP_NAME) + '/' + SUPPORT_INTVL_FILENAME f = open(filepath, 'wb') pickle.dump(self.clocks.times_to_flip, f) return
def dump_clocks_data(self): filepath = application_support(APP_NAME) + '/' + SUPPORT_CLOCKS_FILENAME f = open(filepath, 'wb') pickle.dump(self.clocks.clock_keys, f) return
import requests import geopy from geopy.geocoders import Nominatim from error import LocationNotFoundError from climacell import ClimaCell, APIKeyError from ip_api import get_ip_location from config import Config, valid_config ssl._create_default_https_context = ssl._create_unverified_context APP_NAME = 'WeatherBar' GEOCODER = Nominatim(user_agent=APP_NAME) INTERVAL_SECONDS = 300 CONFIG_NAME = 'config.json' APP_SUPPORT_DIR = rumps.application_support(APP_NAME) CONFIG = Config(APP_SUPPORT_DIR, CONFIG_NAME) WEATHER_ICONS = { '☀️': ['clear'], '⛅': ['partly_cloudy'], '⛈': ['tstorm'], '🌤': ['mostly_clear'], '🌥': ['mostly_cloudy'], '☁️': ['cloudy'], '🌧': ['rain_heavy', 'rain', 'rain_light', 'drizzle'], '🌨': [ 'snow_heavy', 'snow', 'snow_light', 'flurries',