Esempio n. 1
0
    def _load(self, account):
        self.account = account

        # Create home directory
        utils.make_dir('')
        self.configfile = utils.get_root_filename('config.json')

        # Create user directory
        userfolder = "%s.%s" % (account['username'], account['api'])
        utils.make_dir(userfolder)

        self.msg.info(self.name, 'Trackma v{0} - using account {1}({2}).'.format(
            utils.VERSION, account['username'], account['api']))
        self.msg.info(self.name, 'Reading config files...')
        try:
            self.config = utils.parse_config(self.configfile, utils.config_defaults)
        except IOError:
            raise utils.EngineFatal("Couldn't open config file.")

        # Load hook file
        if os.path.exists(utils.get_root_filename('hook.py')):
            import sys
            sys.path[0:0] = [utils.get_root()]
            try:
                self.msg.info(self.name, "Importing user hooks (hook.py)...")
                global hook
                import hook
                self.hooks_available = True
            except ImportError:
                self.msg.warn(self.name, "Error importing hooks.")
            del sys.path[0]
Esempio n. 2
0
 def __init__(self, messenger, tracker_list, process_name, watch_dir, interval, update_wait, update_close, not_found_prompt):
     self.config = utils.parse_config(utils.get_root_filename('config.json'), utils.config_defaults)
     self.host_port = self.config['plex_host']+":"+self.config['plex_port']
     self.update_wait = update_wait
     self.status_log = [None, None]
     self.token = self._get_plex_token()
     super().__init__(messenger, tracker_list, process_name, watch_dir, interval, update_wait, update_close, not_found_prompt)
Esempio n. 3
0
    def _load(self, account):
        self.account = account

        # Create home directory
        utils.make_dir('')
        self.configfile = utils.get_root_filename('config.json')

        # Create user directory
        userfolder = "%s.%s" % (account['username'], account['api'])
        utils.make_dir(userfolder)

        self.msg.info(
            self.name, 'Trackma v{0} - using account {1}({2}).'.format(
                utils.VERSION, account['username'], account['api']))
        self.msg.info(self.name, 'Reading config files...')
        try:
            self.config = utils.parse_config(self.configfile,
                                             utils.config_defaults)
        except IOError:
            raise utils.EngineFatal("Couldn't open config file.")

        # Load hook files
        hooks_dir = utils.get_root_filename('hooks')
        if os.path.isdir(hooks_dir):
            import sys
            import pkgutil

            self.msg.info(self.name, "Importing user hooks...")
            for loader, name, ispkg in pkgutil.iter_modules([hooks_dir]):
                # List all the hook files in the hooks folder, import them
                # and call the init() function if they have them
                # We build the list "hooks available" with the loaded modules
                # for later calls.
                try:
                    self.msg.debug(self.name,
                                   "Importing hook {}...".format(name))
                    module = loader.find_module(name).load_module(name)
                    if hasattr(module, 'init'):
                        module.init(self)
                    self.hooks_available.append(module)
                except ImportError:
                    self.msg.warn(self.name,
                                  "Error importing hook {}.".format(name))
Esempio n. 4
0
    def __init__(self):
        """Creates main widgets and creates mainloop"""
        self.config = utils.parse_config(utils.get_root_filename('ui-curses.json'), utils.curses_defaults)
        keymap = self.config['keymap']
        self.keymap_str = self.get_keymap_str(keymap)
        self.keymapping = self.map_key_to_func(keymap)

        palette = []
        for k, color in self.config['palette'].items():
            palette.append( (k, color[0], color[1]) )

        sys.stdout.write("\x1b]0;Trackma-curses "+utils.VERSION+"\x07");
        self.header_title = urwid.Text('Trackma-curses ' + utils.VERSION)
        self.header_api = urwid.Text('API:')
        self.header_filter = urwid.Text('Filter:')
        self.header_sort = urwid.Text('Sort:title')
        self.header_order = urwid.Text('Order:d')
        self.header = urwid.AttrMap(urwid.Columns([
            self.header_title,
            ('fixed', 23, self.header_filter),
            ('fixed', 17, self.header_sort),
            ('fixed', 16, self.header_api)]), 'status')

        top_pile = [self.header]

        if self.config['show_help']:
            top_text = "{help}:Help  {sort}:Sort  " + \
                       "{update}:Update  {play}:Play  " + \
                       "{status}:Status  {score}:Score  " + \
                       "{quit}:Quit"
            top_text = top_text.format(**self.keymap_str)
            top_pile.append(urwid.AttrMap(urwid.Text(top_text), 'status'))

        self.top_pile = urwid.Pile(top_pile)
        self.statusbar = urwid.AttrMap(urwid.Text('Trackma-curses '+utils.VERSION), 'status')

        self.listheader = urwid.AttrMap(
            urwid.Columns([
                ('weight', 1, urwid.Text('Title')),
                ('fixed', 10, urwid.Text('Progress')),
                ('fixed', 7, urwid.Text('Score')),
            ]), 'header')

        self.listwalker = ShowWalker([])
        self.listbox = urwid.ListBox(self.listwalker)
        self.listframe = urwid.Frame(self.listbox, header=self.listheader)

        self.viewing_info = False

        self.view = urwid.Frame(self.listframe, header=self.top_pile, footer=self.statusbar)
        self.mainloop = urwid.MainLoop(self.view, palette, unhandled_input=self.keystroke, screen=urwid.raw_display.Screen())

        self.mainloop.set_alarm_in(0, self.do_switch_account)
        self.mainloop.run()
Esempio n. 5
0
    def _load(self, account):
        self.account = account

        # Create home directory
        utils.make_dir('')
        self.configfile = utils.get_root_filename('config.json')

        # Create user directory
        userfolder = "%s.%s" % (account['username'], account['api'])
        utils.make_dir(userfolder)

        self.msg.info(self.name, 'Trackma v{0} - using account {1}({2}).'.format(
            utils.VERSION, account['username'], account['api']))
        self.msg.info(self.name, 'Reading config files...')
        try:
            self.config = utils.parse_config(self.configfile, utils.config_defaults)
        except IOError:
            raise utils.EngineFatal("Couldn't open config file.")

        # Load hook files
        hooks_dir = utils.get_root_filename('hooks')
        if os.path.isdir(hooks_dir):
            import sys
            import pkgutil

            self.msg.info(self.name, "Importing user hooks...")
            for loader, name, ispkg in pkgutil.iter_modules([hooks_dir]):
                # List all the hook files in the hooks folder, import them
                # and call the init() function if they have them
                # We build the list "hooks available" with the loaded modules
                # for later calls.
                try:
                    self.msg.debug(self.name, "Importing hook {}...".format(name))
                    module = loader.find_module(name).load_module(name)
                    if hasattr(module, 'init'):
                        module.init(self)
                    self.hooks_available.append(module)
                except ImportError:
                    self.msg.warn(self.name, "Error importing hook {}.".format(name))
Esempio n. 6
0
def get_config():
	configfile = utils.get_root_filename('config.json')
	try:
		config = utils.parse_config(configfile, utils.config_defaults)
	except IOError:
		raise utils.EngineFatal("Couldn't open config file.")

	plex_host_port = config['plex_host']+":"+config['plex_port']

	if config['tracker_type'] == "plex":
		enabled = True
	else:
		enabled = False

	return [enabled, plex_host_port]
Esempio n. 7
0
def get_config():
    # get configs from file
    configfile = utils.get_root_filename('config.json')
    try:
        config = utils.parse_config(configfile, utils.config_defaults)
    except IOError:
        raise utils.EngineFatal("Couldn't open config file.")

    plex_host_port = config['plex_host']+":"+config['plex_port']

    if config['tracker_type'] == "plex":
        enabled = True
    else:
        enabled = False

    return [enabled, plex_host_port]
Esempio n. 8
0
 def __init__(self):
     utils.make_dir('')
     self.filename = utils.get_root_filename('accounts.dict')
     self._load()
Esempio n. 9
0
 def __init__(self):
     utils.make_dir('')
     self.filename = utils.get_root_filename('accounts.dict')
     self._load()
Esempio n. 10
0
    def __init__(self):
        """Creates main widgets and creates mainloop"""
        self.config = utils.parse_config(
            utils.get_root_filename('ui-curses.json'), utils.curses_defaults)
        keymap = utils.curses_defaults['keymap']
        keymap.update(self.config['keymap'])
        self.keymap_str = self.get_keymap_str(keymap)
        self.keymapping = self.map_key_to_func(keymap)

        palette = []
        for k, color in self.config['palette'].items():
            palette.append((k, color[0], color[1]))

        # Prepare header
        sys.stdout.write("\x1b]0;Trackma-curses " + utils.VERSION + "\x07")
        self.header_title = urwid.Text('Trackma-curses ' + utils.VERSION)
        self.header_api = urwid.Text('API:')
        self.header_filter = urwid.Text('Filter:')
        self.header_sort = urwid.Text('Sort:title')
        self.header_order = urwid.Text('Order:d')
        self.header = urwid.AttrMap(
            urwid.Columns([
                self.header_title, ('fixed', 30, self.header_filter),
                ('fixed', 17, self.header_sort), ('fixed', 16, self.header_api)
            ]), 'status')

        top_pile = [self.header]

        if self.config['show_help']:
            top_text = "{help}:Help  {sort}:Sort  " + \
                       "{update}:Update  {play}:Play  " + \
                       "{status}:Status  {score}:Score  " + \
                       "{quit}:Quit"
            top_text = top_text.format(**self.keymap_str)
            top_pile.append(urwid.AttrMap(urwid.Text(top_text), 'status'))

        self.top_pile = urwid.Pile(top_pile)

        # Prepare status bar
        self.status_text = urwid.Text('Trackma-curses ' + utils.VERSION)
        self.status_queue = urwid.Text('Q:N/A')
        self.status_tracker = urwid.Text('T:N/A')
        self.statusbar = urwid.AttrMap(
            urwid.Columns([
                self.status_text,
                ('fixed', 10, self.status_tracker),
                ('fixed', 6, self.status_queue),
            ]), 'status')

        self.listheader = urwid.AttrMap(
            urwid.Columns([
                ('weight', 1, urwid.Text('Title')),
                ('fixed', 10, urwid.Text('Progress')),
                ('fixed', 7, urwid.Text('Score')),
            ]), 'header')

        self.listwalker = ShowWalker([])
        self.listbox = urwid.ListBox(self.listwalker)
        self.listframe = urwid.Frame(self.listbox, header=self.listheader)

        self.viewing_info = False

        self.view = urwid.Frame(self.listframe,
                                header=self.top_pile,
                                footer=self.statusbar)
        self.mainloop = urwid.MainLoop(self.view,
                                       palette,
                                       unhandled_input=self.keystroke,
                                       screen=urwid.raw_display.Screen())

        self.mainloop.set_alarm_in(0, self.do_switch_account)
        self.mainloop.run()
Esempio n. 11
0
    def __init__(self):
        """Creates main widgets and creates mainloop"""

        palette = [
        ('body','', ''),
        ('focus','standout', ''),
        ('head','light red', 'black'),
        ('header','bold', ''),
        ('status', 'white', 'dark blue'),
        ('error', 'light red', 'dark blue'),
        ('window', 'white', 'dark blue'),
        ('button', 'black', 'light gray'),
        ('button hilight', 'white', 'dark red'),
        ('item_airing', 'dark blue', ''),
        ('item_notaired', 'yellow', ''),
        ('item_neweps', 'white', 'brown'),
        ('item_updated', 'white', 'dark green'),
        ('item_playing', 'white', 'dark blue'),
        ('info_title', 'light red', ''),
        ('info_section', 'dark blue', ''),
        ]

        keymap = utils.parse_config(utils.get_root_filename('keymap.json'), utils.keymap_defaults)
        self.keymapping = self.map_key_to_func(keymap)

        sys.stdout.write("\x1b]0;Trackma-curses "+utils.VERSION+"\x07");
        self.header_title = urwid.Text('Trackma-curses ' + utils.VERSION)
        self.header_api = urwid.Text('API:')
        self.header_filter = urwid.Text('Filter:')
        self.header_sort = urwid.Text('Sort:title')
        self.header_order = urwid.Text('Order:d')
        self.header = urwid.AttrMap(urwid.Columns([
            self.header_title,
            ('fixed', 23, self.header_filter),
            ('fixed', 17, self.header_sort),
            ('fixed', 16, self.header_api)]), 'status')


        top_text = keymap['help'] + ':Help  ' + keymap['sort'] +':Sort  ' + \
                   keymap['update'] + ':Update  ' + keymap['play'] + ':Play  ' + \
                   keymap['status'] + ':Status  ' + keymap['score'] + ':Score  ' + \
                   keymap['quit'] + ':Quit'
        self.top_pile = urwid.Pile([self.header,
            urwid.AttrMap(urwid.Text(top_text), 'status')
        ])

        self.statusbar = urwid.AttrMap(urwid.Text('Trackma-curses '+utils.VERSION), 'status')

        self.listheader = urwid.AttrMap(
            urwid.Columns([
                ('weight', 1, urwid.Text('Title')),
                ('fixed', 10, urwid.Text('Progress')),
                ('fixed', 7, urwid.Text('Score')),
            ]), 'header')

        self.listwalker = ShowWalker([])
        self.listbox = urwid.ListBox(self.listwalker)
        self.listframe = urwid.Frame(self.listbox, header=self.listheader)

        self.viewing_info = False

        self.view = urwid.Frame(self.listframe, header=self.top_pile, footer=self.statusbar)
        self.mainloop = urwid.MainLoop(self.view, palette, unhandled_input=self.keystroke, screen=urwid.raw_display.Screen())

        self.mainloop.set_alarm_in(0, self.do_switch_account)
        self.mainloop.run()