Beispiel #1
0
    def sign_in(self, onetime_code=None):
        """ Load token. If not available the user must provide a
            one time code from https://my.remarkable.com/connect/remarkable
        """

        try:
            # Get device token if not stored local
            device_token = cfg.get("authentication.device_token")
            if device_token == None:
                if onetime_code is None or onetime_code == "":
                    self.listener_handler.publish(EVENT_ONETIMECODE_NEEDED)
                    return

                device_token = self._get_device_token(onetime_code)
                if device_token is None:
                    self.listener_handler.publish(EVENT_DEVICE_TOKEN_FAILED)
                    return

            # Renew the user token.
            user_token = self._get_user_token(device_token)
            if user_token is None:
                self.listener_handler.publish(EVENT_USER_TOKEN_FAILED)
                return

            # Save tokens to config
            auth = {"device_token": device_token, "user_token": user_token}
            cfg.save({"authentication": auth})

            # Inform all subscriber
            self.listener_handler.publish(EVENT_SUCCESS, auth)
        except:
            auth = {}
            self.listener_handler.publish(EVENT_FAILED, auth)

        return auth
Beispiel #2
0
    def btn_apply_scaling(self):
        scaling_text = self.scaling_text.get().strip()
        try:
            if len(scaling_text) >= 2 and scaling_text[-1] == "%":
                scaling = float(scaling_text[0:-1]) / 100
            else:
                scaling = float(scaling_text)
        except ValueError:
            return

        print("scaling: ", scaling)
        cfg.save({"scaling": scaling})
Beispiel #3
0
    def save_config(self):
        adsrconf = config.get('adsr')
        for param in adsr_params.keys():
            adsrconf[param] = getattr(self.adsrList, param)

        sounds = config.get('sounds')
        sounds['files'] = self.sounds[:]

        globs = config.get('globals')
        globs['invert_control'] = self.invert_control
        globs['trigger_shadow'] = self.trigger_shadow
        globs['default_volume'] = self.sldVolumen.value()
        globs['sensor_count'] = len(self.players)

        config.save()
Beispiel #4
0
def update_league_path():
    """ Finds and saves the correct League of Legends path to the config """
    # standard League of Legends folder location for macOS / Windows
    if sys.platform == "darwin":
        league_path = "/Applications/League of Legends.app/Contents/LoL"
        macos = True
    elif sys.platform == "win32":
        league_path = "C:\Riot Games\League of Legends"
        macos = False
    else:
        # Exit if used on another platform than macOS / Windows
        raise SystemExit("Operating system not supported.")

    # check if a custom path is already saved in ~/.lolbuilds/config.json
    saved_path = config.get("path")
    if saved_path is not None:
        league_path = saved_path

    # ask for a custom path if standard path is incorrect
    if not os.path.isdir(league_path):
        windows_path = "C:\Program Files\Riot Games\League of Legends"
        mac_path = "/Applications/League of Legends.app"
        print(
            f"Can't find the League of Legends folder at the standard location ({league_path})")
        print("Please type or paste the correct League of Legends path.")
        print(f"Example: { mac_path if macos else windows_path }")
        print()

        league_path = input()
        while not os.path.isdir(league_path) or "league of legends" not in league_path.lower():
            print("Please point to the League of Legends folder/app")
            print(f"Example: { mac_path if macos else windows_path }")
            league_path = input()

        clear()
        print_script_info()

        # open app content on macOS
        if macos:
            league_path = os.path.join(league_path, "Contents/LoL")

    # save the path in a config file in ~/.lolbuilds/config.json
    config.save("path", league_path)

    print(f"Found League of Legends at {league_path}")
Beispiel #5
0
 def __del__(self):
   config.save(self.__dict__, 'systemconfig')
   d = {}
   for item in dir(self):
     if not item.startswith("__"):
       if item.startswith("PR_"):
         d[item] = getattr(self,item)
   od = OrderedDict(sorted(d.items(), key=lambda t: t[0]))
   items = od.items() # Because we terminate in reverse order
   items.reverse()
   rod = OrderedDict(items)
   for item, value in rod.iteritems():
     try:
       output = subprocess.check_call("sudo kill " + str(value.pid), shell=True)
       time.sleep(1)
       if output != 0:
         logging.error("EGDoor.systemconfig, error executing last command: %s" % command)
     except Exception as e:
       logging.error("EGDoor.systemconfig Exception terminating daemon item: %s, %s" % (item, e))
Beispiel #6
0
 def btn_save_click(self):
     general = {
         "templates": self.entry_templates_text.get(),
         "backuproot": self.backup_root_text.get()
     }
     cfg.save({"general": general})
Beispiel #7
0
#!/usr/bin/env python

import os
import sys

__DIR_PATH = os.path.dirname(os.path.realpath(__file__))
__ROOT_PATH = os.path.join(__DIR_PATH, '..')
if __ROOT_PATH not in sys.path:
    sys.path.append(__ROOT_PATH)

from utils import config

DB_PATH = os.path.join(__DIR_PATH, '../data/amazonsharp.db')

config.set_value(config.DB_NAME, DB_PATH)
config.save()