Exemple #1
0
def main():
    home_ct = os.path.join(os.environ['HOME'], '.ct')
    if 'CT_HOME' not in os.environ or not os.path.isdir(os.environ['CT_HOME']):
        if not os.path.isdir(home_ct):
            log.info('Creating ~/.ct')
            os.mkdir(home_ct)
        os.environ['CT_HOME'] = os.path.join(os.environ['HOME'], '.ct')

    parser = argparse.ArgumentParser(prog='ct',
                                     description='Time tracking tool')

    subparsers = parser.add_subparsers(title='subcommands',
                                       help='Type "ct [command] --help" for more information.')

    for name, cmd in commands.viewitems():
        cmd = cmd()
        new_parser = subparsers.add_parser(name, description=cmd.description)
        new_parser.add_argument('--config', default=False, action='store_true',
                                dest='config', help='update configuration options')
        cmd.add_arguments(new_parser)
        new_parser.set_defaults(func=cmd.execute)

    parser.add_argument('--config', default=False, action='store_true',
                        dest='config', help='update configuration options')

    args = parser.parse_args()
    if args.config:
        load_config(reset=True)
    args.func(args)
Exemple #2
0
 def update_adium(self, format_str, project, time, away):
     conf = load_config()
     if conf['adium']:
         time_str = time.strftime(user_date_format)
         adium_str = (format_str % dict(location=conf['location'],
                                        project=project,
                                        time=time_str))
         if set_adium_status(adium_str + blurb, away):
             log.info('Updated Adium status to: %s' % adium_str)
         else:
             log.info("Couldn't update Adium status")