Пример #1
0
def pull(dry_run, flavor):
    """ Pull down tasks from forges and add them to your taskwarrior tasks.

    Relies on configuration in bugwarriorrc
    """
    twiggy.quickSetup()
    try:
        main_section = _get_section_name(flavor)

        # Load our config file
        config = load_config(main_section)

        tw_config = TaskWarriorBase.load_config(get_taskrc_path(config, main_section))
        lockfile_path = os.path.join(os.path.expanduser(tw_config["data"]["location"]), "bugwarrior.lockfile")

        lockfile = PIDLockFile(lockfile_path)
        lockfile.acquire(timeout=10)
        try:
            # Get all the issues.  This can take a while.
            issue_generator = aggregate_issues(config, main_section)

            # Stuff them in the taskwarrior db as necessary
            synchronize(issue_generator, config, main_section, dry_run)
        finally:
            lockfile.release()
    except LockTimeout:
        log.name("command").critical(
            "Your taskrc repository is currently locked. "
            "Remove the file at %s if you are sure no other "
            "bugwarrior processes are currently running." % (lockfile_path)
        )
    except:
        log.name("command").trace("error").critical("oh noes")
Пример #2
0
def pull(dry_run, flavor, interactive, debug):
    """ Pull down tasks from forges and add them to your taskwarrior tasks.

    Relies on configuration in bugwarriorrc
    """

    try:
        main_section = _get_section_name(flavor)
        config = _try_load_config(main_section, interactive)

        lockfile_path = os.path.join(get_data_path(config, main_section),
                                     'bugwarrior.lockfile')
        lockfile = PIDLockFile(lockfile_path)
        lockfile.acquire(timeout=10)
        try:
            # Get all the issues.  This can take a while.
            issue_generator = aggregate_issues(config, main_section, debug)

            # Stuff them in the taskwarrior db as necessary
            synchronize(issue_generator, config, main_section, dry_run)
        finally:
            lockfile.release()
    except LockTimeout:
        log.critical(
            'Your taskrc repository is currently locked. '
            'Remove the file at %s if you are sure no other '
            'bugwarrior processes are currently running.' % (
                lockfile_path
            )
        )
    except RuntimeError as e:
        log.critical("Aborted (%s)" % e)
Пример #3
0
def pull(dry_run, flavor, interactive, debug):
    """ Pull down tasks from forges and add them to your taskwarrior tasks.

    Relies on configuration in bugwarriorrc
    """

    try:
        main_section = _get_section_name(flavor)
        config = _try_load_config(main_section, interactive)

        lockfile_path = os.path.join(get_data_path(config, main_section),
                                     'bugwarrior.lockfile')
        lockfile = PIDLockFile(lockfile_path)
        lockfile.acquire(timeout=10)
        try:
            # Get all the issues.  This can take a while.
            issue_generator = aggregate_issues(config, main_section, debug)

            # Stuff them in the taskwarrior db as necessary
            synchronize(issue_generator, config, main_section, dry_run)
        finally:
            lockfile.release()
    except LockTimeout:
        log.critical('Your taskrc repository is currently locked. '
                     'Remove the file at %s if you are sure no other '
                     'bugwarrior processes are currently running.' %
                     (lockfile_path))
    except RuntimeError as e:
        log.exception("Aborted (%s)" % e)
Пример #4
0
def pull():
    """ Pull down tasks from forges and add them to your taskwarrior tasks.

    Relies on configuration in ~/.bugwarriorrc
    """
    twiggy.quickSetup()
    try:
        # Load our config file
        config = load_config()

        tw_config = TaskWarriorBase.load_config(get_taskrc_path(config))
        lockfile_path = os.path.join(
            os.path.expanduser(tw_config['data']['location']),
            'bugwarrior.lockfile')

        lockfile = PIDLockFile(lockfile_path)
        lockfile.acquire(timeout=10)
        try:
            # Get all the issues.  This can take a while.
            issue_generator = aggregate_issues(config)

            # Stuff them in the taskwarrior db as necessary
            synchronize(issue_generator, config)
        finally:
            lockfile.release()
    except LockTimeout:
        log.name('command').critical(
            'Your taskrc repository is currently locked. '
            'Remove the file at %s if you are sure no other '
            'bugwarrior processes are currently running.' % (lockfile_path))
    except:
        log.name('command').trace('error').critical('oh noes')
Пример #5
0
def pull():
    try:
        # Load our config file
        config = load_config()

        # Get all the issues.  This can take a while.
        issues = aggregate_issues(config)

        # Stuff them in the taskwarrior db as necessary
        synchronize(issues, config)
    except:
        log.name('command').trace('error').critical('oh noes')
Пример #6
0
def pull():
    try:
        # Load our config file
        config = load_config()

        # Get all the issues.  This can take a while.
        issues = aggregate_issues(config)

        # Stuff them in the taskwarrior db as necessary
        synchronize(issues)
    except:
        log.trace("error").critical("oh noes")
Пример #7
0
def pull():
    """ Pull down tasks from forges and add them to your taskwarrior tasks.

    Relies on configuration in ~/.bugwarriorrc
    """
    twiggy.quickSetup()
    try:
        # Load our config file
        config = load_config()

        tw_config = TaskWarriorBase.load_config(get_taskrc_path(config))
        lockfile_path = os.path.join(
            os.path.expanduser(
                tw_config['data']['location']
            ),
            'bugwarrior.lockfile'
        )

        lockfile = PIDLockFile(lockfile_path)
        lockfile.acquire(timeout=10)
        try:
            # Get all the issues.  This can take a while.
            issue_generator = aggregate_issues(config)

            # Stuff them in the taskwarrior db as necessary
            synchronize(issue_generator, config)
        finally:
            lockfile.release()
    except LockTimeout:
        log.name('command').critical(
            'Your taskrc repository is currently locked. '
            'Remove the file at %s if you are sure no other '
            'bugwarrior processes are currently running.' % (
                lockfile_path
            )
        )
    except:
        log.name('command').trace('error').critical('oh noes')
Пример #8
0
    def test_synchronize(self):
        def get_tasks(tw):
            tasks = tw.load_tasks()

            # Remove non-deterministic keys.
            del tasks['pending'][0]['modified']
            del tasks['pending'][0]['entry']
            del tasks['pending'][0]['uuid']

            return tasks

        config = ConfigParser.RawConfigParser()
        config.add_section('general')
        config.set('general', 'targets', 'my_service')
        config.add_section('my_service')
        config.set('my_service', 'service', 'github')

        tw = taskw.TaskWarrior(self.taskrc)
        self.assertEqual(tw.load_tasks(), {'completed': [], 'pending': []})

        issue = {
            'description': 'Blah blah blah. ☃',
            'githubtype': 'issue',
            'githuburl': 'https://example.com',
            'priority': 'M',
        }

        # TEST NEW ISSUE AND EXISTING ISSUE.
        for _ in range(2):
            db.synchronize(iter((issue, )), config, 'general')

            self.assertEqual(
                get_tasks(tw), {
                    'completed': [],
                    'pending': [{
                        u'priority': u'M',
                        u'status': u'pending',
                        u'description': u'Blah blah blah. ☃',
                        u'githuburl': u'https://example.com',
                        u'githubtype': u'issue',
                        u'id': 1,
                        u'urgency': 3.9,
                    }]
                })

        # TEST CHANGED ISSUE.
        issue['description'] = 'Yada yada yada.'

        db.synchronize(iter((issue, )), config, 'general')

        self.assertEqual(
            get_tasks(tw), {
                'completed': [],
                'pending': [{
                    u'priority': u'M',
                    u'status': u'pending',
                    u'description': u'Yada yada yada.',
                    u'githuburl': u'https://example.com',
                    u'githubtype': u'issue',
                    u'id': 1,
                    u'urgency': 3.9,
                }]
            })

        # TEST CLOSED ISSUE.
        db.synchronize(iter(()), config, 'general')

        tasks = tw.load_tasks()

        # Remove non-deterministic keys.
        del tasks['completed'][0]['modified']
        del tasks['completed'][0]['entry']
        del tasks['completed'][0]['end']
        del tasks['completed'][0]['uuid']

        self.assertEqual(
            tasks, {
                'completed': [{
                    u'description': u'Yada yada yada.',
                    u'githubtype': u'issue',
                    u'githuburl': u'https://example.com',
                    u'id': 0,
                    u'priority': u'M',
                    u'status': u'completed',
                    u'urgency': 3.9,
                }],
                'pending': []
            })
Пример #9
0
    def test_synchronize(self):

        def get_tasks(tw):
            tasks = tw.load_tasks()

            # Remove non-deterministic keys.
            del tasks['pending'][0]['modified']
            del tasks['pending'][0]['entry']
            del tasks['pending'][0]['uuid']

            return tasks

        config = configparser.RawConfigParser()
        config.add_section('general')
        config.set('general', 'targets', 'my_service')
        config.set('general', 'static_fields', 'project, priority')
        config.add_section('my_service')
        config.set('my_service', 'service', 'github')

        tw = taskw.TaskWarrior(self.taskrc)
        self.assertEqual(tw.load_tasks(), {'completed': [], 'pending': []})

        issue = {
            'description': 'Blah blah blah. ☃',
            'project': 'sample_project',
            'githubtype': 'issue',
            'githuburl': 'https://example.com',
            'priority': 'M',
        }

        # TEST NEW ISSUE AND EXISTING ISSUE.
        for _ in range(2):
            # Use an issue generator with two copies of the same issue.
            # These should be de-duplicated in db.synchronize before
            # writing out to taskwarrior.
            # https://github.com/ralphbean/bugwarrior/issues/601
            issue_generator = iter((issue, issue,))
            db.synchronize(issue_generator, config, 'general')

            self.assertEqual(get_tasks(tw), {
                'completed': [],
                'pending': [{
                    u'project': u'sample_project',
                    u'priority': u'M',
                    u'status': u'pending',
                    u'description': u'Blah blah blah. ☃',
                    u'githuburl': u'https://example.com',
                    u'githubtype': u'issue',
                    u'id': 1,
                    u'urgency': 4.9,
                }]})

        # TEST CHANGED ISSUE.
        issue['description'] = 'Yada yada yada.'

        # Change static field
        issue['project'] = 'other_project'

        db.synchronize(iter((issue,)), config, 'general')

        self.assertEqual(get_tasks(tw), {
            'completed': [],
            'pending': [{
                u'priority': u'M',
                u'project': u'sample_project',
                u'status': u'pending',
                u'description': u'Yada yada yada.',
                u'githuburl': u'https://example.com',
                u'githubtype': u'issue',
                u'id': 1,
                u'urgency': 4.9,
            }]})

        # TEST CLOSED ISSUE.
        db.synchronize(iter(()), config, 'general')

        tasks = tw.load_tasks()

        # Remove non-deterministic keys.
        del tasks['completed'][0]['modified']
        del tasks['completed'][0]['entry']
        del tasks['completed'][0]['end']
        del tasks['completed'][0]['uuid']

        self.assertEqual(tasks, {
            'completed': [{
                u'project': u'sample_project',
                u'description': u'Yada yada yada.',
                u'githubtype': u'issue',
                u'githuburl': u'https://example.com',
                u'id': 0,
                u'priority': u'M',
                u'status': u'completed',
                u'urgency': 4.9,
            }],
             'pending': []})
Пример #10
0
    def test_synchronize(self):

        def get_tasks(tw):
            tasks = tw.load_tasks()

            # Remove non-deterministic keys.
            del tasks['pending'][0]['modified']
            del tasks['pending'][0]['entry']
            del tasks['pending'][0]['uuid']

            return tasks

        config = ConfigParser.RawConfigParser()
        config.add_section('general')
        config.set('general', 'targets', 'my_service')
        config.set('general', 'static_fields', 'project, priority')
        config.add_section('my_service')
        config.set('my_service', 'service', 'github')

        tw = taskw.TaskWarrior(self.taskrc)
        self.assertEqual(tw.load_tasks(), {'completed': [], 'pending': []})

        issue = {
            'description': 'Blah blah blah. ☃',
            'project': 'sample_project',
            'githubtype': 'issue',
            'githuburl': 'https://example.com',
            'priority': 'M',
        }

        # TEST NEW ISSUE AND EXISTING ISSUE.
        for _ in range(2):
            db.synchronize(iter((issue,)), config, 'general')

            self.assertEqual(get_tasks(tw), {
                'completed': [],
                'pending': [{
                    u'project': u'sample_project',
                    u'priority': u'M',
                    u'status': u'pending',
                    u'description': u'Blah blah blah. ☃',
                    u'githuburl': u'https://example.com',
                    u'githubtype': u'issue',
                    u'id': 1,
                    u'urgency': 4.9,
                }]})

        # TEST CHANGED ISSUE.
        issue['description'] = 'Yada yada yada.'

        # Change static field
        issue['project'] = 'other_project'

        db.synchronize(iter((issue,)), config, 'general')

        self.assertEqual(get_tasks(tw), {
            'completed': [],
            'pending': [{
                u'priority': u'M',
                u'project': u'sample_project',
                u'status': u'pending',
                u'description': u'Yada yada yada.',
                u'githuburl': u'https://example.com',
                u'githubtype': u'issue',
                u'id': 1,
                u'urgency': 4.9,
            }]})

        # TEST CLOSED ISSUE.
        db.synchronize(iter(()), config, 'general')

        tasks = tw.load_tasks()

        # Remove non-deterministic keys.
        del tasks['completed'][0]['modified']
        del tasks['completed'][0]['entry']
        del tasks['completed'][0]['end']
        del tasks['completed'][0]['uuid']

        self.assertEqual(tasks, {
            'completed': [{
                u'project': u'sample_project',
                u'description': u'Yada yada yada.',
                u'githubtype': u'issue',
                u'githuburl': u'https://example.com',
                u'id': 0,
                u'priority': u'M',
                u'status': u'completed',
                u'urgency': 4.9,
            }],
             'pending': []})