コード例 #1
0
ファイル: runjsclient.py プロジェクト: bergheim/ct
def do_ct_login(username, password):
    server = config.get("server", "ct_url")
    ct = SimpleAPI(server)
    logged_in = ct.login(username, password)
    if logged_in:
        session['user'] = username
        session['ct'] = ct

    return logged_in
コード例 #2
0
ファイル: list_activities.py プロジェクト: asbjorn/ct
config.read([default_cfg, user_cfg])

server = config.get("server", "url")
username = config.get("login", "username")
password = config.get("login", "password")


now = datetime.datetime.now()

parser = argparse.ArgumentParser()
parser.add_argument('-m', dest='month', type=int, default=now.month,
   help='The month number to list hours from, defaults to current month')
parser.add_argument('-y', dest='year', type=int, default=now.year,
   help='The year to list hours from, defaults to current year')
args = parser.parse_args()

ct = SimpleAPI(server)
if ct.login(username, password):
    result = defaultdict(lambda: 0)
    for activity in ct.get_activities(args.year, args.month):
        result[activity.project_id] += activity.duration

    project_map = dict([(p.id, p) for p in ct.get_projects()])
    for project_id, worked in sorted(result.items()):
        if not worked:
            continue

        print "%04s: %s" % (worked, project_map[project_id].name)
else:
    print "Could not login."
コード例 #3
0
ファイル: list_projects.py プロジェクト: asbjorn/ct
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be interpreted
# as representing official policies, either expressed or implied, of
# Alf Lervåg.

import os
import sys
from ct.apis import SimpleAPI
import ConfigParser

config = ConfigParser.ConfigParser()
user_cfg = os.path.expanduser('~/.ct.cfg')
default_cfg = os.path.join(
    sys.prefix,
    'share/ct/config.ini.sample')

config.read([default_cfg, user_cfg])

server = config.get("server", "url")
username = config.get("login", "username")
password = config.get("login", "password")


ct = SimpleAPI(server)
if ct.login(username, password):
    projects = ct.get_projects()
    for project in sorted(projects):
        print "%s (%s)" % (project.name, project.id)
else:
    print "Could not login."