def retrieve(self): """ retrieve HotList tasks """ #parse arguments loglevel = 'WARNING' parser = argparse.ArgumentParser( description='Notify toodledo tasks with Growl for windows.') parser.add_argument('--log', dest='loglevel', default='WARNING', help='level of logging (default: WARNING)') args = parser.parse_args() #parse config current_dir = os.path.dirname(os.path.abspath(__file__)) config_file = os.path.join(current_dir, 'toodledo2growl.cnf') config = ConfigParser.SafeConfigParser() config.read([config_file]) # config logging numeric_level = getattr(logging, args.loglevel.upper(), None) if not isinstance(numeric_level, int): raise ValueError('Invalid log level: %s' % loglevel) logging.basicConfig(level=numeric_level) # create Toodledo Client app_id = config.get('credential', 'app_id') app_token = config.get('credential', 'app_token') logging.debug(': '.join(['Client app_id', app_id])) logging.debug(': '.join(['Client app_token', app_token])) api = ApiClient(app_id=app_id, app_token=app_token) logging.info('created Toodledo Client') # Toodledo Authentication email = config.get('credential', 'email') password = config.get('credential', 'password') logging.debug(': '.join(['Auth email', email])) logging.debug(': '.join(['Auth password', password])) api.authenticate(email, password) logging.info('Auth Toodledo') # Get AccountInfo account_info = api.getAccountInfo() logging.debug(': '.join(['AccountInfo', str(account_info)])) # Get Task list from Toodledo task_list = api.getTasks(fields="duedate,star,priority,parent") logging.info(': '.join(['Got task list', str(len(task_list))])) for task in self._HotlistFilter(account_info, task_list): if task.parent != 0: parent = api.getTask(task.parent) task.title = parent.title + '.' + task.title yield task