summaryrefslogtreecommitdiffstats
path: root/git_taskrepo/sub_commands/cmd_update.py
blob: 91f30dbdc4540413ff2af19c03a6ba28c8983162 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

# -*- coding: utf-8 -*-

import sys, os
from git_taskrepo.command import Command
from git_taskrepo.taskrepo import update_taskrepo, parse_testinfo, TRX

class Update(Command):
    """Update Task Repo"""
    enabled = True

    def options(self):
        self.parser.usage = "%%prog %s [<path/to/task>]" % self.normalized_name

    def run(self, *args, **kwargs):
        self.set_repo(**kwargs)
        self.set_taskrepo(**kwargs)
        if len(args) >= 1:
            taskpath = os.path.normpath(os.path.join(os.getcwd(), args[0]))
        else:
            taskpath = os.getcwd()
        sys.stderr.write("[TaskRepo] Updating %s ... " % taskpath)
        try:
            update_taskrepo(self.repo, self.taskrepo, taskpath)
        except TRX, e:
            sys.stderr.write("FAIL (%s).\n" % e)
            sys.exit(1)
        else:
            sys.stderr.write("done.\n")