예제 #1
0
    def _load(self, account):
        self.account = account

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

        # Create user directory
        userfolder = "%s.%s" % (account['username'], account['api'])
        utils.make_dir(utils.to_data_path(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.")

        # Expand media directories and ignore those that don't exist
        if isinstance(self.config['searchdir'], str):
            # Compatibility: Turn a string of a single directory into a list
            self.msg.debug(self.name, "Fixing string searchdir to list.")
            self.config['searchdir'] = [self.config['searchdir']]

        self.searchdirs = [path for path in utils.expand_paths(
            self.config['searchdir']) if self._searchdir_exists(path)]
예제 #2
0
파일: engine.py 프로젝트: z411/trackma
    def _load(self, account):
        self.account = account

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

        # Create user directory
        userfolder = "%s.%s" % (account['username'], account['api'])
        utils.make_dir(utils.to_data_path(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.")

        # Expand media directories and ignore those that don't exist
        if isinstance(self.config['searchdir'], str):
            # Compatibility: Turn a string of a single directory into a list
            self.msg.debug(self.name, "Fixing string searchdir to list.")
            self.config['searchdir'] = [self.config['searchdir']]

        self.searchdirs = [path for path in utils.expand_paths(self.config['searchdir']) if self._searchdir_exists(path)]
예제 #3
0
파일: engine.py 프로젝트: zJoul/trackma
    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]
예제 #4
0
 def purge_account(self, num):
     """
     Renames stale cache files for account number **num**.
     """
     account = self.accounts['accounts'][num]
     userfolder = "%s.%s" % (account['username'], account['api'])
     utils.make_dir(userfolder + '.old')
     utils.regex_rename_files('(.*.queue)|(.*.info)|(.*.list)|(.*.meta)', userfolder, userfolder + '.old')
예제 #5
0
 def purge_account(self, num):
     """
     Renames stale cache files for account number **num**.
     """
     account = self.accounts['accounts'][num]
     userfolder = "%s.%s" % (account['username'], account['api'])
     utils.make_dir(userfolder + '.old')
     utils.regex_rename_files('(.*.queue)|(.*.info)|(.*.list)|(.*.meta)',
                              userfolder, userfolder + '.old')
예제 #6
0
    def _update_widgets_for_selected_show(self):
        if not self._current_page.selected_show:
            self.set_buttons_sensitive(False, lists_too=False)
            return

        self.set_buttons_sensitive(True, lists_too=False)
        show = self._engine.get_show_info(self._current_page.selected_show)

        # Block handlers
        self.statusbox.handler_block(self.statusbox_handler)

        if self._image_thread is not None:
            self._image_thread.cancel()

        self.show_title.set_text('<span size="14000"><b>{0}</b></span>'.format(
            html.escape(show['title'])))
        self.show_title.set_use_markup(True)

        # Episode selector
        self.btn_episode_show_entry.set_label(str(show['my_progress']))
        self._hide_episode_entry()

        # Status selector
        for i in self.statusmodel:
            if str(i[0]) == str(show['my_status']):
                self.statusbox.set_active_iter(i.iter)
                break

        # Score selector
        self.spinbtn_score.set_value(show['my_score'])

        # Image
        if show.get('image_thumb') or show.get('image'):
            utils.make_dir(utils.to_cache_path())
            filename = utils.to_cache_path(
                "%s_%s_%s.jpg" %
                (self._engine.api_info['shortname'],
                 self._engine.api_info['mediatype'], show['id']))

            if os.path.isfile(filename):
                self.show_image.image_show(filename)
            else:
                if imaging_available:
                    self.show_image.pholder_show('Loading...')
                    self._image_thread = ImageTask(
                        self.show_image,
                        show.get('image_thumb') or show['image'], filename,
                        (100, 149))
                    self._image_thread.start()
                else:
                    self.show_image.pholder_show("PIL library\nnot available")
        else:
            self.show_image.pholder_show("No Image")

        # Unblock handlers
        self.statusbox.handler_unblock(self.statusbox_handler)
예제 #7
0
파일: mainview.py 프로젝트: z411/trackma
    def _update_widgets_for_selected_show(self):
        if not self._current_page.selected_show:
            self.set_buttons_sensitive(False, lists_too=False)
            return

        self.set_buttons_sensitive(True, lists_too=False)
        show = self._engine.get_show_info(self._current_page.selected_show)

        # Block handlers
        self.statusbox.handler_block(self.statusbox_handler)

        if self._image_thread is not None:
            self._image_thread.cancel()

        self.show_title.set_text('<span size="14000"><b>{0}</b></span>'.format(html.escape(show['title'])))
        self.show_title.set_use_markup(True)

        # Episode selector
        self.btn_episode_show_entry.set_label(str(show['my_progress']))
        self._hide_episode_entry()

        # Status selector
        for i in self.statusmodel:
            if str(i[0]) == str(show['my_status']):
                self.statusbox.set_active_iter(i.iter)
                break

        # Score selector
        self.spinbtn_score.set_value(show['my_score'])

        # Image
        if show.get('image_thumb') or show.get('image'):
            utils.make_dir(utils.to_cache_path())
            filename = utils.to_cache_path(
                "%s_%s_%s.jpg" % (self._engine.api_info['shortname'],
                                  self._engine.api_info['mediatype'],
                                  show['id']))

            if os.path.isfile(filename):
                self.show_image.image_show(filename)
            else:
                if imaging_available:
                    self.show_image.pholder_show('Loading...')
                    self._image_thread = ImageTask(self.show_image,
                                                   show.get('image_thumb') or show['image'],
                                                   filename,
                                                   (100, 149))
                    self._image_thread.start()
                else:
                    self.show_image.pholder_show("PIL library\nnot available")
        else:
            self.show_image.pholder_show("No Image")

        # Unblock handlers
        self.statusbox.handler_unblock(self.statusbox_handler)
예제 #8
0
    def _update_widgets_for_selected_show(self):
        if not (self._current_page and self._current_page.selected_show):
            self.set_buttons_sensitive(False, lists_too=False)
            return

        self.set_buttons_sensitive(True, lists_too=False)
        try:
            show = self._engine.get_show_info(self._current_page.selected_show)
        except utils.EngineError:
            self._list.remove(id=self._current_page.selected_show)
            self.set_buttons_sensitive(False, lists_too=False)
            return

        # Block handlers
        self.statusbox.handler_block(self.statusbox_handler)

        if self._image_thread is not None:
            self._image_thread.cancel()

        self.show_title.set_text('<span size="14000"><b>{0}</b></span>'.format(
            html.escape(show['title'])))
        self.show_title.set_use_markup(True)

        # Episode selector
        self.btn_episode_show_entry.set_label(str(show['my_progress']))

        # Status selector
        for i in self.statusmodel:
            if str(i[0]) == str(show['my_status']):
                self.statusbox.set_active_iter(i.iter)
                break

        # Score selector
        self.spinbtn_score.set_value(show['my_score'])

        # Image
        if show.get('image_thumb') or show.get('image'):
            utils.make_dir(utils.to_cache_path())
            filename = utils.to_cache_path(
                "%s_%s_%s.jpg" %
                (self._engine.api_info['shortname'],
                 self._engine.api_info['mediatype'], show['id']))

            if os.path.isfile(filename):
                self.image_box.set_image(filename)
            else:
                self.image_box.set_image_remote(
                    show.get('image_thumb') or show['image'], filename)
        else:
            self.image_box.set_text('No Image')

        # Unblock handlers
        self.statusbox.handler_unblock(self.statusbox_handler)
예제 #9
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))
예제 #10
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))
예제 #11
0
 def __init__(self):
     utils.make_dir('')
     self.filename = utils.get_root_filename('accounts.dict')
     self._load()
예제 #12
0
 def __init__(self):
     utils.make_dir('')
     self.filename = utils.get_root_filename('accounts.dict')
     self._load()
예제 #13
0
 def __init__(self):
     utils.make_dir(utils.to_config_path())
     self.filename = utils.to_config_path('accounts.dict')
     self._load()
예제 #14
0
파일: accounts.py 프로젝트: z411/trackma
 def __init__(self):
     utils.make_dir(utils.to_config_path())
     self.filename = utils.to_config_path('accounts.dict')
     self._load()