def list_(args): """List the tracker's issues (filtered by criteria)""" t = args['tracker'] c = UserConfig() query = Query(t) args.setdefault('order', 'updated') args.setdefault('status', 'open') issues = query.select(order_by=args['order'], status=args['status']) # short mode if args['short']: for i in issues: print '%s %s' % (c.decorate('red', i.id[:6]), i.title) # normal mode else: for i in issues: print '%s %s' % (c.decorate('red', 'issue'), i.id) print '%s %s <%s>' % (c.decorate( 'yellow', 'Author:'), i.author['name'], i.author['email']) print '%s %s' % (c.decorate('yellow', 'Created:'), relative_time(i.created)) if i.updated != i.created: print '%s %s' % (c.decorate( 'yellow', 'Updated:'), relative_time(i.updated)) print '%s %s' % (c.decorate('yellow', 'Status:'), i.status) num_comments = len(i.comments()) if num_comments: print '%d Comments' % num_comments print print ' ' + c.decorate('bold', i.title) print content = wrap(i.content) for line in content.splitlines(): print ' ' + line print
def new(args): """Create a new issue.""" t = args['tracker'] i = Issue(t) config = UserConfig() # set the author info i.author['name'] = config.user['name'] i.author['email'] = config.user['email'] # no editor for inline calls if args['message'] is not None: i.title = args['message'] i.content = '.' else: # get the user's editor editor = args['editor'] if args['editor'] else config.core['editor'] # the Template object opens templates in the editor and parses them. template = IssueTemplate('new.hpr') path = template.open(editor) fields = template.parse(path) i.title = fields['title'] i.content = fields['content'] if i.save(): # commit the changes if config.core['autocommit']: t.autocommit(message='Created a new issue %s' % i.id[:6], author=config.user) print 'Created issue %s' % i.id[:6]
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
def list_(args): """List the tracker's issues (filtered by criteria)""" t = args['tracker'] c = UserConfig() query = Query(t) args.setdefault('order', 'updated') args.setdefault('status', 'open') issues = query.select(order_by=args['order'], status=args['status']) # short mode if args['short']: for i in issues: print '%s %s' % (c.decorate('red', i.id[:6]), i.title) # normal mode else: for i in issues: print '%s %s' % (c.decorate('red', 'issue'), i.id) print '%s %s <%s>' % (c.decorate('yellow', 'Author:'), i.author['name'], i.author['email']) print '%s %s' % (c.decorate('yellow', 'Created:'), relative_time(i.created)) if i.updated != i.created: print '%s %s' % (c.decorate('yellow', 'Updated:'), relative_time(i.updated)) print '%s %s' % (c.decorate('yellow', 'Status:'), i.status) num_comments = len(i.comments()) if num_comments: print '%d Comments' % num_comments print print ' ' + c.decorate('bold', i.title) print content = wrap(i.content) for line in content.splitlines(): print ' ' + line print
def comment(args): """Comment on an issue.""" t = args['tracker'] i = t.issue(args['issue']) if not i: print 'No such issue' return c = Comment(i) config = UserConfig() # set the author info c.author['name'] = config.user['name'] c.author['email'] = config.user['email'] editor = args['editor'] if args['editor'] else config.core['editor'] template = Template('comment.hpr') path = template.open(editor) fields = template.parse(path) c.content = fields['content'] if c.save() and i.save(): # commit the changes if config.core['autocommit']: t.autocommit(message='Commented on issue %s' % i.id[:6], author=config.user) print 'Posted comment %s on issue %s' % (c.id[:3], i.id[:6])
from __future__ import with_statement from flask import Flask from hopper.config import UserConfig # Create the app app = Flask(__name__) # Get the Secret Key from the user onfig c = UserConfig() app.secret_key = c.web['secret_key'] # We need to share a few vars between scripts: app.GLOBALS = { 'debug': True, 'first_request': True, # give the user a env context msg } # Import blueprints from hopper.web.views.issues import issues from hopper.web.views.docs import docs from hopper.web.views.feed import feed from hopper.web.views.settings import settings from hopper.web.views.api import api # Register blueprints app.register_blueprint(issues, url_prefix='/issues') app.register_blueprint(docs, url_prefix='/docs') app.register_blueprint(settings, url_prefix='/settings') app.register_blueprint(api, url_prefix='/api') app.register_blueprint(feed)
def show(args): """Show an issue.""" t = args['tracker'] c = UserConfig() try: i = t.issue(args['issue']) except AmbiguousReference: print c.decorate('yellow', 'Multiple matches. Try adding another character.') return except BadReference: print c.decorate('red', 'No issue matched that id.') return print '%s %s' % (c.decorate('red', 'issue'), i.id) print '%s %s <%s>' % (c.decorate( 'yellow', 'Author:'), i.author['name'], i.author['email']) print '%s %s' % (c.decorate('yellow', 'Created:'), relative_time( i.created)) if i.updated != i.created: print '%s %s' % (c.decorate('yellow', 'Updated:'), relative_time(i.updated)) print '%s %s' % (c.decorate('yellow', 'Status:'), i.status) print print ' ' + c.decorate('bold', i.title) print content = wrap(i.content) for line in content.splitlines(): print ' ' + line print
def show(args): """Show an issue.""" t = args['tracker'] c = UserConfig() try: i = t.issue(args['issue']) except AmbiguousReference: print c.decorate('yellow', 'Multiple matches. Try adding another character.') return except BadReference: print c.decorate('red', 'No issue matched that id.') return print '%s %s' % (c.decorate('red', 'issue'), i.id) print '%s %s <%s>' % (c.decorate('yellow', 'Author:'), i.author['name'], i.author['email']) print '%s %s' % (c.decorate('yellow', 'Created:'), relative_time(i.created)) if i.updated != i.created: print '%s %s' % (c.decorate('yellow', 'Updated:'), relative_time(i.updated)) print '%s %s' % (c.decorate('yellow', 'Status:'), i.status) print print ' ' + c.decorate('bold', i.title) print content = wrap(i.content) for line in content.splitlines(): print ' ' + line print