Пример #1
0
def get_tracker(path=None):
    """Get the tracker or raise an error."""
    if path is None:
        cwd = os.getcwd()
        if is_tracker(cwd):
            return Tracker(cwd)
        else:
            raise OSError('The cwd is not a Hopper tracker')
    elif os.path.exists(path) and is_tracker(path):
        return Tracker(path)
    raise OSError('The supplied path is not a Hopper tracker')
Пример #2
0
    def test_constructor(self):
        # supplying non-existent paths should raise OSError
        try:
            Tracker(self.path)
        except OSError:
            pass

        # supplying a valid path should work.
        t1 = Tracker.new(self.path)
        t2 = Tracker(t1.paths['root'])
        assert type(t2) is Tracker
Пример #3
0
    def test_new(self):
        # verify that new() returns a Tracker object.
        t = Tracker.new(self.path)
        assert type(t) is Tracker

        # verfify that the tracker was created on disk.
        assert os.path.isdir(t.paths['root'])
Пример #4
0
 def make_tracker(self, direc=None, name=None):
     '''
     Make a tracker in the current directory with the given or a
     randomly generated name. This is called automatically on init.
     It is left public for scenarios where having multiple trackers
     is desired.
     '''
     if name is not None:
         path = name
     else:
         path = get_uuid()
     if direc is not None:
         path = os.path.join(direc, path)
     return Tracker.new(path)
Пример #5
0
 def make_tracker(self, direc=None, name=None):
     '''
     Make a tracker in the current directory with the given or a
     randomly generated name. This is called automatically on init.
     It is left public for scenarios where having multiple trackers
     is desired.
     '''
     if name is not None:
         path = name
     else:
         path = get_uuid()
     if direc is not None:
         path = os.path.join(direc, path)
     return Tracker.new(path)
Пример #6
0
    def test_issue(self):
        t = Tracker.new(self.path)
        i1 = Issue(t)
        i1.save()
        i2 = t.issue(i1.id)
        # verify that issue() returns an Issue
        assert type(i2) is Issue
        # verify that the issues match
        assert i1.fields == i2.fields

        # invalid SHAs should raise BadReference
        invalid_sha = get_uuid()
        try:
            t.issue(invalid_sha)
        except BadReference:
            pass
Пример #7
0
def setup():
    """
    Return the tracker and config. 
    
    It also sets the flash to an environment warning to let the user know
    they are running the tracker locally and as <name>. We only do this
    the first time setup() is called per web server process.
    """
    config = UserConfig()
    # Use current_app so we don't have circular imports.
    tracker = Tracker(current_app.GLOBALS['tracker'])
    if current_app.GLOBALS['first_request']:
        flash('Running Hopper locally as %s' % config.user['name'])
        current_app.GLOBALS['first_request'] = False
        # Make sure the SQLite db is in sync with the JSON db.
        tracker.db._replicate()
    return tracker, config
Пример #8
0
 def test_issues(self):
     t = Tracker.new(self.path)
     # make a bunch of issues
     issues = [Issue(t) for i in range(50)]
Пример #9
0
def create_tracker(args):
    Tracker.new(args['path'])
    print 'New tracker initialized. Edit %s to configure.' % \
            os.path.join(args['path'], 'config')
Пример #10
0
def create_tracker(args):
    Tracker.new(args['path'])
    print 'New tracker initialized. Edit %s to configure.' % \
            os.path.join(args['path'], 'config')