rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
elif column == 'reporter' and cell.find('@') != -1: value['rss'] = cell
elif column == 'reporter': if cell.find('@') != -1: value['rss'] = cell elif cell in email_map: value['rss'] = email_map[cell]
def sortkey(row): val = row[colIndex] if isinstance(val, basestring): val = val.lower() return val
info[fields[i]] = escape(row[i] or '')
if type(row[i]) is StringType: info[fields[i]] = escape(row[i] or '') else: info[fields[i]] = row[i] or ''
def get_ticket (self, id): global fields cnx = db.get_connection () cursor = cnx.cursor ()
def has_node(self, path, rev):
def has_node(self, path, rev=None):
def has_node(self, path, rev): """ Tell if there's a node at the specified (path,rev) combination. """ try: self.get_node() return True except TracError: return False
self.get_node()
self.get_node(path, rev)
def has_node(self, path, rev): """ Tell if there's a node at the specified (path,rev) combination. """ try: self.get_node() return True except TracError: return False
for line in lines: if not line.startswith('--- '): continue words = line.split(None, 2) filename, fromrev = words[1], 'old' groups, blocks = None, None
try:
def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * '  ' + mod * ' '
if not line.startswith('+++ '): return None words = line.split(None, 2) if len(words[1]) < len(filename): filename = words[1] groups = [] output.append({'filename' : filename, 'oldrev' : fromrev, 'newrev' : 'new', 'diff' : groups}) for line in lines: r = re.match(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@', line) if not r:...
while True: if not line.startswith('--- '):
def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * '&nbsp; ' + mod * '&nbsp;'
command, line = line[0], line[1:] if (command == ' ') != last_type: last_type = command == ' ' blocks.append({'type': last_type and 'unmod' or 'mod', 'base.offset': fromline - 1, 'base.lines': [], 'changed.offset': toline - 1, 'changed.lines': []}) if command == ' ': blocks[-1]['changed.lines'].append(line) blocks[-1]...
continue words = line.split(None, 2) filename, fromrev = words[1], 'old' groups, blocks = None, None line = lines.next() if not line.startswith('+++ '): return None words = line.split(None, 2) if len(words[1]) < len(filename): filename = words[1] groups = [] output.append({'filename' : filename, 'oldrev' : fromre...
def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * '&nbsp; ' + mod * '&nbsp;'
if req.method == 'POST' and 'owner' in req.args and \
if req.method == 'POST' and 'field_owner' in req.args and \
def process_newticket_request(self, req): req.perm.require('TICKET_CREATE') data = {} db = self.env.get_db_cnx()
del req.args['owner']
del req.args['field_owner']
def process_newticket_request(self, req): req.perm.require('TICKET_CREATE') data = {} db = self.env.get_db_cnx()
ticket.populate(req.args)
self._populate(req, ticket)
def process_newticket_request(self, req): req.perm.require('TICKET_CREATE') data = {} db = self.env.get_db_cnx()
ticket.populate(req.args)
self._populate(req, ticket)
def process_ticket_request(self, req): req.perm.require('TICKET_VIEW') data = {}
if 'summary' not in req.args:
if 'field_summary' not in req.args:
def _do_create(self, req, db): if 'summary' not in req.args: raise TracError('Tickets must contain a summary.')
ticket.populate(req.args)
self._populate(req, ticket)
def _do_create(self, req, db): if 'summary' not in req.args: raise TracError('Tickets must contain a summary.')
if not req.args.get('summary'):
if not req.args.get('field_summary'):
def _do_save(self, req, db, ticket): if 'TICKET_CHGPROP' in req.perm: # TICKET_CHGPROP gives permission to edit the ticket if not req.args.get('summary'): raise TracError('Tickets must contain summary.')
if req.args.has_key('description') or req.args.has_key('reporter'):
if 'field_description' in req.args or 'field_reporter' in req.args:
def _do_save(self, req, db, ticket): if 'TICKET_CHGPROP' in req.perm: # TICKET_CHGPROP gives permission to edit the ticket if not req.args.get('summary'): raise TracError('Tickets must contain summary.')
ticket.populate(req.args)
self._populate(req, ticket)
def _do_save(self, req, db, ticket): if 'TICKET_CHGPROP' in req.perm: # TICKET_CHGPROP gives permission to edit the ticket if not req.args.get('summary'): raise TracError('Tickets must contain summary.')
req.hdf['report.query_href'] = self.env.href.report()
req.hdf['report.query_href'] = self.env.href.query()
def process_request(self, req): req.perm.assert_permission(perm.REPORT_VIEW)
text = wiki_to_oneliner(heading, self.env, self.db, True, self._absurls)
text = wiki_to_oneliner(heading, self.env, self.db, False, self._absurls)
def _heading_formatter(self, match, fullmatch): match = match.strip() self.close_table() self.close_paragraph() self.close_indentation() self.close_list() self.close_def_list()
time_to_string (int(changeset_info['time'])))
time.asctime (time.localtime(int(changeset_info['time']))))
def render (self): perm.assert_permission (perm.CHANGESET_VIEW) if self.args.has_key('rev'): self.rev = int(self.args['rev']) else: self.rev = fs.youngest_rev(self.fs_ptr, self.pool)
_help_permission = [('permission list', 'List permission rules'),
_help_permission = [('permission list [user]', 'List permission rules'),
def _do_component_set_owner(self, name, owner): cnx = self.db_open() cursor = cnx.cursor () cursor.execute('SELECT name FROM component WHERE name=%s', name) data = cursor.fetchone() if not data: raise Exception("No such component '%s'" % name) data = self.db_execsql("UPDATE component SET owner='%s' WHERE name='%s'" % (...
self._do_permission_list()
user = None if len(arg) > 1: user = arg[1] self._do_permission_list(user)
def do_permission(self, line): arg = self.arg_tokenize(line) try: if arg[0] == 'list': self._do_permission_list() elif arg[0] == 'add' and len(arg) >= 3: user = arg[1] for action in arg[2:]: self._do_permission_add(user, action) elif arg[0] == 'remove' and len(arg) >= 3: user = arg[1] for action in arg[2:]: self._do_...
def _do_permission_list(self): data = self.db_execsql('SELECT username, action FROM permission ' \ 'ORDER BY username, action')
def _do_permission_list(self, user=None): if user: data = self.db_execsql("SELECT username, action FROM permission " "WHERE username='%s' ORDER BY action" % user) else: data = self.db_execsql("SELECT username, action FROM permission " "ORDER BY username, action")
def _do_permission_list(self): data = self.db_execsql('SELECT username, action FROM permission ' \ 'ORDER BY username, action') self.print_listing(['User', 'Action'], data) print print 'Available actions:' actions = perm.permissions + perm.meta_permissions.keys() actions.sort() text = ', '.join(actions) print util.wrap...
try: t = time.strptime(_from, '%x') except: t = time.localtime()
t = time.localtime() if _from: try: t = time.strptime(_from, '%x') except: pass
def render (self): self.perm.assert_permission(perm.TIMELINE_VIEW)
req.args['format'] = match.group(1) and 'raw' or ''
if match.group(1): req.args['format'] = 'raw'
def match_request(self, req): match = re.match(r'^/(raw-)?attachment/([^/]+)(?:[/:](.*))?$', req.path_info) if match: req.args['format'] = match.group(1) and 'raw' or '' req.args['type'] = match.group(2) req.args['path'] = match.group(3).replace(':', '/') return True
self.setup_config() self.setup_log()
self.setup_config(load_defaults=create) self.setup_log()
def __init__(self, path, create=False, options=[]): """Initialize the Trac environment. @param path: the absolute path to the Trac environment @param create: if `True`, the environment is created and populated with default data; otherwise, the environment is expected to already exist. @param options: A list of `(sec...
self.setup_config() for section, default_options in self.config.defaults().items(): for name, value in default_options.items(): self.config.set(section, name, value)
self.setup_config(load_defaults=True)
def _create_file(fname, data=None): fd = open(fname, 'w') if data: fd.write(data) fd.close()
def setup_config(self):
def setup_config(self, load_defaults=False):
def setup_config(self): """Load the configuration file.""" self.config = Configuration(os.path.join(self.path, 'conf', 'trac.ini'))
repos = self.__env.get_repository()
def do_resync(self, line): print 'Resyncing repository history...' cnx = self.db_open() cursor = cnx.cursor() cursor.execute("DELETE FROM revision") cursor.execute("DELETE FROM node_change") repos = self.__env.get_repository() cursor.execute("DELETE FROM system WHERE name='repository_dir'") repos.sync() print 'Done.'
repos.sync()
repos = self.__env.get_repository()
def do_resync(self, line): print 'Resyncing repository history...' cnx = self.db_open() cursor = cnx.cursor() cursor.execute("DELETE FROM revision") cursor.execute("DELETE FROM node_change") repos = self.__env.get_repository() cursor.execute("DELETE FROM system WHERE name='repository_dir'") repos.sync() print 'Done.'
params = []
def render_macro(self, req, name, content): prefix = limit = None if content: argv = [arg.strip() for arg in content.split(',')] if len(argv) > 0: prefix = argv[0].replace('\'', '\'\'') if len(argv) > 1: limit = int(argv[1])
sql += 'WHERE name LIKE %s%% ' params.append(prefix)
sql += "WHERE name LIKE '%s%%' " % prefix
def render_macro(self, req, name, content): prefix = limit = None if content: argv = [arg.strip() for arg in content.split(',')] if len(argv) > 0: prefix = argv[0].replace('\'', '\'\'') if len(argv) > 1: limit = int(argv[1])
cursor.execute(sql, params)
cursor.execute(sql)
def render_macro(self, req, name, content): prefix = limit = None if content: argv = [arg.strip() for arg in content.split(',')] if len(argv) > 0: prefix = argv[0].replace('\'', '\'\'') if len(argv) > 1: limit = int(argv[1])
def save(self, author, comment, remote_addr, t=time.time(), db=None):
def save(self, author, comment, remote_addr, t=None, db=None):
def save(self, author, comment, remote_addr, t=time.time(), db=None): if not db: db = self.env.get_db_cnx() handle_ta = True else: handle_ta = False
raise util.TracError('Invalid revision number: %d' % rev) history = svn.fs.node_history(root, self.path, self.pool) history = svn.fs.history_prev(history, 0, self.pool)
rev = svn.fs.youngest_rev(self.fs_ptr, self.pool) root = svn.fs.revision_root(self.fs_ptr, rev, self.pool) node_type = svn.fs.check_path(root, self.path, self.pool) if not node_type in [svn.core.svn_node_dir, svn.core.svn_node_file]: rev = svn.fs.youngest_rev(self.fs_ptr, self.pool) root = svn.fs.revision_root(self.fs...
def render(self): FileCommon.render(self) rev = self.args.get('rev', None) self.path = self.args.get('path', '/') if not rev: rev_specified = 0 rev = svn.fs.youngest_rev(self.fs_ptr, self.pool) else: rev_specified = 1 try: rev = int(rev) except ValueError: rev_specified = 0 rev = svn.fs.youngest_rev(self.fs_ptr, self....
text = data[0][0]
text = data.next()[0]
def _do_wiki_export(self, page, filename=''): data = self.db_query("SELECT text FROM wiki WHERE name='%s' " "ORDER BY version DESC LIMIT 1" % page) text = data[0][0] if not filename: print text else: if os.path.isfile(filename): raise Exception("File '%s' exists" % filename) f = open(filename,'w') f.write(text) f.close...
links.append('<a class="%s ticket" href="%s" ' 'title="%s"> summary, ticket['id']))
a = '<a class="%s ticket" href="%s" title="%s"> (ticket['status'], href, summary, ticket['id']) links.append(a)
def render_macro(self, req, name, content): query_string = '' compact = 0 argv = content.split(',') if len(argv) > 0: query_string = argv[0] if len(argv) > 1: if argv[1].strip().lower() == 'compact': compact = 1 try: from cStringIO import StringIO except NameError: from StringIO import StringIO buf = StringIO()
buf.write('<dt><a href="%s"> ticket['id']))
dt = '<dt><a class="%s ticket" href="%s"> (ticket['status'], href, ticket['id']) buf.write(dt)
def render_macro(self, req, name, content): query_string = '' compact = 0 argv = content.split(',') if len(argv) > 0: query_string = argv[0] if len(argv) > 1: if argv[1].strip().lower() == 'compact': compact = 1 try: from cStringIO import StringIO except NameError: from StringIO import StringIO buf = StringIO()
def validate_ticket(req, ticket):
def _validate_ticket(self, req, ticket):
def validate_ticket(req, ticket): for manipulator in self.ticket_manipulators: for field, message in manipulator.validate_ticket(req, ticket): if field: raise TracError("The ticket %s field is invalid: %s" % (field, message)) else: raise TracError("Invalid ticket: %s" % message)
self.validate_ticket(req, ticket)
def process_request(self, req): req.perm.assert_permission('TICKET_CREATE')
self.validate_ticket(req, ticket)
self._validate_ticket(req, ticket)
def _do_create(self, req, db): if not req.args.get('summary'): raise TracError('Tickets must contain a summary.')
self.validate_ticket(req, ticket)
self._validate_ticket(req, ticket)
def process_request(self, req): req.perm.assert_permission('TICKET_VIEW')
self.validate_ticket(req, ticket)
self._validate_ticket(req, ticket)
def _do_save(self, req, db, ticket): if req.perm.has_permission('TICKET_CHGPROP'): # TICKET_CHGPROP gives permission to edit the ticket if not req.args.get('summary'): raise TracError('Tickets must contain summary.')
depth = int((len(fullmatch.group('ldepth')) + 1) / 2)
ldepth = len(fullmatch.group('ldepth')) depth = int((ldepth + 1) / 2)
def _listitem_formatter(self, match, fullmatch): depth = int((len(fullmatch.group('ldepth')) + 1) / 2) #self.out.write('depth:%d' % depth) type = ['ol', 'ul'][match[depth * 2 - 1] == '*'] self._li_open = 1 self._set_list_depth(depth, type) return '<li>' #return '<li>%s</li>' % match[depth * 2 + 1:]
type = ['ol', 'ul'][match[depth * 2 - 1] == '*']
type = ['ol', 'ul'][match[ldepth] == '*']
def _listitem_formatter(self, match, fullmatch): depth = int((len(fullmatch.group('ldepth')) + 1) / 2) #self.out.write('depth:%d' % depth) type = ['ol', 'ul'][match[depth * 2 - 1] == '*'] self._li_open = 1 self._set_list_depth(depth, type) return '<li>' #return '<li>%s</li>' % match[depth * 2 + 1:]
self.order = 'priority'
if order == 'created': order = 'time' elif order == 'modified': order = 'changetime' if order in ['time', 'changetime']: self.order = order else: self.order = 'priority'
def __init__(self, env, constraints=None, order=None, desc=0, group=None, groupdesc = 0, verbose=0): self.env = env self.constraints = constraints or {} self.order = order self.desc = desc self.group = group self.groupdesc = groupdesc self.verbose = verbose self.fields = TicketSystem(self.env).get_ticket_fields() self....
while 1: row = cursor.fetchone() if not row: break if len(info) == 0:
for idx, row in enum(cursor): if idx == 0:
def get_info(self, req, start, stop, maxrows, filters=AVAILABLE_FILTERS): perm_map = {'ticket': perm.TICKET_VIEW, 'changeset': perm.CHANGESET_VIEW, 'wiki': perm.WIKI_VIEW, 'milestone': perm.MILESTONE_VIEW} filters = list(filters) # copy list so we can make modifications for k,v in perm_map.items(): if k in filters and ...
while 1: row = cursor.fetchone() if not row: break
class_map = {'A': 'diff-add', 'M': 'diff-mod', 'D': 'diff-rem'} for name,change in cursor:
def _render_changeset(self, req, item): absurls = req.args.get('format') == 'rss' href = self.env.href if absurls: href = self.env.abs_href
if not self.authzperm.has_permission(row_node['name']):
if not self.authzperm.has_permission(name):
def _render_changeset(self, req, item): absurls = req.args.get('format') == 'rss' href = self.env.href if absurls: href = self.env.abs_href
if row[1] == 'A': files.append('<span class="diff-add">%s</span>' % row[0]) elif row[1] == 'M': files.append('<span class="diff-mod">%s</span>' % row[0]) elif row[1] == 'D': files.append('<span class="diff-rem">%s</span>' % row[0])
files.append('<span class="%s">%s</span>' % (class_map[change], name))
def _render_changeset(self, req, item): absurls = req.args.get('format') == 'rss' href = self.env.href if absurls: href = self.env.abs_href
hdf.setValue('trac.authname', req.authname)
hdf.setValue('trac.authname', util.escape(req.authname))
def populate_hdf(hdf, env, db, req): sql_to_hdf(db, "SELECT name FROM enum WHERE type='priority' " "ORDER BY value", hdf, 'enums.priority') sql_to_hdf(db, "SELECT name FROM enum WHERE type='severity' " "ORDER BY value", hdf, 'enums.severity') htdocs_location = env.get_config('trac', 'htdocs_location') if htdocs_locati...
def insert(self, filename, fileobj, size, time=time.time(), db=None):
def insert(self, filename, fileobj, size, t=None, db=None):
def insert(self, filename, fileobj, size, time=time.time(), db=None): if not db: db = self.env.get_db_cnx() handle_ta = True else: handle_ta = False
self.time = time
self.time = t or time.time()
def insert(self, filename, fileobj, size, time=time.time(), db=None): if not db: db = self.env.get_db_cnx() handle_ta = True else: handle_ta = False
if num == 0:
if num < 0:
def htmlify(match): m = match.group('spaces') if m: div, mod = divmod(len(m), 2) return div * '&nbsp; ' + mod * '&nbsp;' return (match.group('tag') or '') + '&nbsp;'
listener.wiki_page_changed(self)
listener.wiki_page_changed(self, self.version, t, author, comment, remote_addr)
def save(self, author, comment, remote_addr, t=time.time(), db=None): if not db: db = self.env.get_db_cnx() handle_ta = True else: handle_ta = False
self.deletions.pop(old_path)
del self.deletions[old_path]
def finalize(self): """ The rename detection is deferred until the end of edition, as 'delete' and 'add' notifications can happen in any order. """ for node_type, path, old_path, old_rev, action in self.additions: if self.deletions.has_key(old_path): # normal rename self.deletions.pop(old_path) action = 'R' elif self.d...
self.deletions.pop(path)
del self.deletions[path]
def finalize(self): """ The rename detection is deferred until the end of edition, as 'delete' and 'add' notifications can happen in any order. """ for node_type, path, old_path, old_rev, action in self.additions: if self.deletions.has_key(old_path): # normal rename self.deletions.pop(old_path) action = 'R' elif self.d...
return re.match('/(login|logout)/?', req.path_info)
return re.match('/(login|logout)/?$', req.path_info)
def match_request(self, req): return re.match('/(login|logout)/?', req.path_info)
info = ''
def produce((id, ts, author, type, summary), status, fields, comment, cid): if status == 'edit': if 'ticket_details' in filters: info = '' if len(fields) > 0: info = ', '.join(['<i>%s</i>' % f for f in \ fields.keys()]) + ' changed<br />' else: return None elif 'ticket' in filters: if status == 'closed' and fields.has_...
info = ', '.join(['<i>%s</i>' % f for f in \ fields.keys()]) + ' changed<br />'
keys = fields.keys() info = html([[html.i(f), ', '] for f in keys[:-1]], html.i(keys[-1]), ' changed', html.br())
def produce((id, ts, author, type, summary), status, fields, comment, cid): if status == 'edit': if 'ticket_details' in filters: info = '' if len(fields) > 0: info = ', '.join(['<i>%s</i>' % f for f in \ fields.keys()]) + ' changed<br />' else: return None elif 'ticket' in filters: if status == 'closed' and fields.has_...
info = '%s: ' % info else: info = ''
info += ': '
def produce((id, ts, author, type, summary), status, fields, comment, cid): if status == 'edit': if 'ticket_details' in filters: info = '' if len(fields) > 0: info = ', '.join(['<i>%s</i>' % f for f in \ fields.keys()]) + ' changed<br />' else: return None elif 'ticket' in filters: if status == 'closed' and fields.has_...
title = Markup('Ticket <em title="%s"> summary, id, type, verb)
title = html('Ticket ', html.em(' ' (', verb, ')')
def produce((id, ts, author, type, summary), status, fields, comment, cid): if status == 'edit': if 'ticket_details' in filters: info = '' if len(fields) > 0: info = ', '.join(['<i>%s</i>' % f for f in \ fields.keys()]) + ' changed<br />' else: return None elif 'ticket' in filters: if status == 'closed' and fields.has_...
message = summary
markup = summary
def produce((id, ts, author, type, summary), status, fields, comment, cid): if status == 'edit': if 'ticket_details' in filters: info = '' if len(fields) > 0: info = ', '.join(['<i>%s</i>' % f for f in \ fields.keys()]) + ' changed<br />' else: return None elif 'ticket' in filters: if status == 'closed' and fields.has_...
markup = Markup(info)
markup = info
def produce((id, ts, author, type, summary), status, fields, comment, cid): if status == 'edit': if 'ticket_details' in filters: info = '' if len(fields) > 0: info = ', '.join(['<i>%s</i>' % f for f in \ fields.keys()]) + ' changed<br />' else: return None elif 'ticket' in filters: if status == 'closed' and fields.has_...
if text[0:2] in ['++', '--']: return
def writeline(self, text): if text[0:2] in ['++', '--']: return match = line_re.search(text) if match: self.print_block() self.changeno += 1 self.blockno = 0 self.offset_base = int(match.group(1)) - 1 self.offset_changed = int(match.group(3)) - 1 return ttype = text[0] text = text[1:] text = text.expandtabs(self.tabwid...
ttype = text[0] text = text[1:] text = text.expandtabs(self.tabwidth)
elif not self.changeno: return ttype, text = text[0], text[1:].expandtabs(self.tabwidth)
def writeline(self, text): if text[0:2] in ['++', '--']: return match = line_re.search(text) if match: self.print_block() self.changeno += 1 self.blockno = 0 self.offset_base = int(match.group(1)) - 1 self.offset_changed = int(match.group(3)) - 1 return ttype = text[0] text = text[1:] text = text.expandtabs(self.tabwid...
req.hdf = HDFWrapper(loadpaths=[default_dir('templates')])
req.hdf = HDFWrapper(loadpaths)
def send_project_index(environ, start_response, parent_dir=None, env_paths=None): from trac.config import default_dir req = Request(environ, start_response) loadpaths = [default_dir('templates')] if req.environ.get('trac.env_index_template'): tmpl_path, template = os.path.split(req.environ['trac.env_index_template'])...
if save or preview: session = Session(self.env, self.req) editrows = self.args.get('editrows') if editrows: self.req.hdf.setValue('wiki.edit_rows', editrows) pref = session.get('wiki_editrows', '20') if editrows != pref: session.set_var('wiki_editrows', editrows) else: self.req.hdf.setValue('wiki.edit_rows', session.ge...
session = Session(self.env, self.req) editrows = self.args.get('editrows') if editrows: self.req.hdf.setValue('wiki.edit_rows', editrows) pref = session.get('wiki_editrows', '20') if editrows != pref: session.set_var('wiki_editrows', editrows) else: self.req.hdf.setValue('wiki.edit_rows', session.get('wiki_editrows', '...
def render(self): name = self.args.get('page', 'WikiStart') author = self.args.get('author', get_reporter_id(self.req)) edit_version = self.args.get('edit_version', None) delete_ver = self.args.get('delete_ver', None) delete_page = self.args.get('delete_page', None) comment = self.args.get('comment', '') save = self.ar...
req.hdf['report.message'] = 'Report failed: %s' % e return info = self.get_info(db, id, args) if not info: return title, description, sql = info
raise TracError, 'Report failed: %s' % e title, description, sql = self.get_info(db, id, args)
def _render_view(self, req, db, id): """ uses a user specified sql query to extract some information from the database and presents it as a html table. """ actions = {'create': perm.REPORT_CREATE, 'delete': perm.REPORT_DELETE, 'modify': perm.REPORT_MODIFY} for action in [k for k,v in actions.items() if req.perm.has_per...
m = re.search(dynvars_re, sql) if not m: return sql aname=m.group()[1:] try: arg = args[aname] except KeyError: raise util.TracError("Dynamic variable '$%s' not defined." % aname) req.hdf['report.var.' + aname] = arg sql = m.string[:m.start()] + arg + m.string[m.end():] return self.sql_sub_vars(req, sql, args)
def repl(match): aname = match.group()[1:] try: arg = args[aname] except KeyError: raise util.TracError("Dynamic variable '$%s' not defined." % aname) req.hdf['report.var.' + aname] = arg return arg return dynvars_re.sub(repl, sql)
def sql_sub_vars(self, req, sql, args): m = re.search(dynvars_re, sql) if not m: return sql aname=m.group()[1:] try: arg = args[aname] except KeyError: raise util.TracError("Dynamic variable '$%s' not defined." % aname) req.hdf['report.var.' + aname] = arg sql = m.string[:m.start()] + arg + m.string[m.end():] return se...
fd.close()
if fd: fd.close()
def verify(self): """Verify that the provided path points to a valid Trac environment directory.""" try: fd = open(os.path.join(self.path, 'VERSION'), 'r') assert fd.read(26) == 'Trac Environment Version 1' finally: fd.close()
self.env = trac.env.Environment(path)
self.env = Environment(path)
def __init__(self, path): self.env = trac.env.Environment(path) self._db = self.env.get_db_cnx() self._db.autocommit = False self.loginNameCache = {} self.fieldNameCache = {}
c.execute('''SELECT count(*) FROM Ticket''')
c.execute("SELECT count(*) FROM Ticket")
def hasTickets(self): c = self.db().cursor() c.execute('''SELECT count(*) FROM Ticket''') return int(c.fetchall()[0][0]) > 0
c.execute("""DELETE FROM enum WHERE type='severity'""")
c.execute("DELETE FROM enum WHERE type='severity'")
def setSeverityList(self, s): """Remove all severities, set them to `s`""" self.assertNoTickets() c = self.db().cursor() c.execute("""DELETE FROM enum WHERE type='severity'""") for value, i in s: print "inserting severity ", value, " ", i c.execute("""INSERT INTO enum (type, name, value) VALUES (%s, %s, %s)""", "sever...
print "inserting severity ", value, " ", i c.execute("""INSERT INTO enum (type, name, value) VALUES (%s, %s, %s)""", "severity", value.encode('utf-8'), i)
print " inserting severity '%s' - '%s'" % (value, i) c.execute("""INSERT INTO enum (type, name, value) VALUES (%s, %s, %s)""", ("severity", value.encode('utf-8'), i))
def setSeverityList(self, s): """Remove all severities, set them to `s`""" self.assertNoTickets() c = self.db().cursor() c.execute("""DELETE FROM enum WHERE type='severity'""") for value, i in s: print "inserting severity ", value, " ", i c.execute("""INSERT INTO enum (type, name, value) VALUES (%s, %s, %s)""", "sever...
c.execute("""DELETE FROM enum WHERE type='priority'""")
c.execute("DELETE FROM enum WHERE type='priority'")
def setPriorityList(self, s): """Remove all priorities, set them to `s`""" self.assertNoTickets() c = self.db().cursor() c.execute("""DELETE FROM enum WHERE type='priority'""") for value, i in s: print "inserting priority ", value, " ", i c.execute("""INSERT INTO enum (type, name, value) VALUES (%s, %s, %s)""", "prior...
print "inserting priority ", value, " ", i c.execute("""INSERT INTO enum (type, name, value) VALUES (%s, %s, %s)""", "priority", value.encode('utf-8'), i)
print " inserting priority '%s' - '%s'" % (value, i) c.execute("""INSERT INTO enum (type, name, value) VALUES (%s, %s, %s)""", ("priority", value.encode('utf-8'), i))
def setPriorityList(self, s): """Remove all priorities, set them to `s`""" self.assertNoTickets() c = self.db().cursor() c.execute("""DELETE FROM enum WHERE type='priority'""") for value, i in s: print "inserting priority ", value, " ", i c.execute("""INSERT INTO enum (type, name, value) VALUES (%s, %s, %s)""", "prior...
c.execute("""DELETE FROM component""")
c.execute("DELETE FROM component")
def setComponentList(self, l, key): """Remove all components, set them to `l`""" self.assertNoTickets() c = self.db().cursor() c.execute("""DELETE FROM component""") for comp in l: print "inserting component '",comp[key],"', owner", comp['owner'] c.execute("""INSERT INTO component (name, owner) VALUES (%s, %s)""", co...
print "inserting component '",comp[key],"', owner", comp['owner'] c.execute("""INSERT INTO component (name, owner) VALUES (%s, %s)""", comp[key].encode('utf-8'), comp['owner'].encode('utf-8'))
print " inserting component '%s', owner '%s'" % \ (comp[key], comp['owner']) c.execute("INSERT INTO component (name, owner) VALUES (%s, %s)", (comp[key].encode('utf-8'), comp['owner'].encode('utf-8')))
def setComponentList(self, l, key): """Remove all components, set them to `l`""" self.assertNoTickets() c = self.db().cursor() c.execute("""DELETE FROM component""") for comp in l: print "inserting component '",comp[key],"', owner", comp['owner'] c.execute("""INSERT INTO component (name, owner) VALUES (%s, %s)""", co...
c.execute("""DELETE FROM version""")
c.execute("DELETE FROM version")
def setVersionList(self, v, key): """Remove all versions, set them to `v`""" self.assertNoTickets() c = self.db().cursor() c.execute("""DELETE FROM version""") for vers in v: print "inserting version ", vers[key] c.execute("""INSERT INTO version (name) VALUES (%s)""", vers[key].encode('utf-8')) self.db().commit()
print "inserting version ", vers[key] c.execute("""INSERT INTO version (name) VALUES (%s)""", vers[key].encode('utf-8'))
print " inserting version '%s'" % (vers[key]) c.execute("INSERT INTO version (name) VALUES (%s)", (vers[key],))
def setVersionList(self, v, key): """Remove all versions, set them to `v`""" self.assertNoTickets() c = self.db().cursor() c.execute("""DELETE FROM version""") for vers in v: print "inserting version ", vers[key] c.execute("""INSERT INTO version (name) VALUES (%s)""", vers[key].encode('utf-8')) self.db().commit()
c.execute("""DELETE FROM milestone""")
c.execute("DELETE FROM milestone")
def setMilestoneList(self, m, key): """Remove all milestones, set them to `m`""" self.assertNoTickets() c = self.db().cursor() c.execute("""DELETE FROM milestone""") for ms in m: print "inserting milestone ", ms[key] c.execute("""INSERT INTO milestone (name) VALUES (%s)""", ms[key].encode('utf-8')) self.db().commit()
print "inserting milestone ", ms[key] c.execute("""INSERT INTO milestone (name) VALUES (%s)""", ms[key].encode('utf-8'))
milestone = ms[key] print " inserting milestone '%s'" % (milestone) c.execute("INSERT INTO milestone (name) VALUES (%s)", (milestone.encode('utf-8')))
def setMilestoneList(self, m, key): """Remove all milestones, set them to `m`""" self.assertNoTickets() c = self.db().cursor() c.execute("""DELETE FROM milestone""") for ms in m: print "inserting milestone ", ms[key] c.execute("""INSERT INTO milestone (name) VALUES (%s)""", ms[key].encode('utf-8')) self.db().commit()
print "inserting ticket %s -- %s" % (id, summary) c.execute("""INSERT INTO ticket (id, time, changetime, component, severity, priority, owner, reporter, cc, version, milestone, status, resolution, summary, description, keywords) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", id, time.strfti...
if REPLACE_BUG_NO: if BUG_NO_RE.search(desc): desc = re.sub(BUG_NO_RE, BUG_NO_REPL, desc) if PRIORITIES_MAP.has_key(priority): priority = PRIORITIES_MAP[priority] print " inserting ticket %s -- %s" % (id, summary) c.execute("""INSERT INTO ticket (id, type, time, changetime, component, severity, priority, owner, rep...
def addTicket(self, id, time, changetime, component, severity, priority, owner, reporter, cc, version, milestone, status, resolution, summary, description, keywords): c = self.db().cursor() desc = description.encode('utf-8') if PREFORMAT_COMMENTS: desc = '{{{\n%s\n}}}' % desc
return self.db().db.sqlite_last_insert_rowid()
return self.db().get_last_id(c, 'ticket')
def addTicket(self, id, time, changetime, component, severity, priority, owner, reporter, cc, version, milestone, status, resolution, summary, description, keywords): c = self.db().cursor() desc = description.encode('utf-8') if PREFORMAT_COMMENTS: desc = '{{{\n%s\n}}}' % desc
c.execute("""INSERT INTO ticket_change (ticket, time, author, field, oldvalue, newvalue) VALUES (%s, %s, %s, %s, %s, %s)""", ticket, time.strftime('%s'), author, 'comment', '', comment)
c.execute("""INSERT INTO ticket_change (ticket, time, author, field, oldvalue, newvalue) VALUES (%s, %s, %s, %s, %s, %s)""", (ticket, time.strftime('%s'), author, 'comment', '', comment))
def addTicketComment(self, ticket, time, author, value): comment = value.encode('utf-8') if PREFORMAT_COMMENTS: comment = '{{{\n%s\n}}}' % comment
c.execute("""INSERT INTO ticket_change (ticket, time, author, field, oldvalue, newvalue) VALUES (%s, %s, %s, %s, %s, %s)""", ticket, time.strftime('%s'), author, field, oldvalue.encode('utf-8'), newvalue.encode('utf-8'))
if field == "priority": if PRIORITIES_MAP.has_key(oldvalue.lower()): oldvalue = PRIORITIES_MAP[oldvalue.lower()] if PRIORITIES_MAP.has_key(newvalue.lower()): newvalue = PRIORITIES_MAP[newvalue.lower()] if oldvalue == newvalue: return c.execute("""INSERT INTO ticket_change (ticket, time, author, field, oldvalue, newv...
def addTicketChange(self, ticket, time, author, field, oldvalue, newvalue): c = self.db().cursor() c.execute("""INSERT INTO ticket_change (ticket, time, author, field, oldvalue, newvalue) VALUES (%s, %s, %s, %s, %s, %s)""", ticket, time.strftime('%s'), author, field, oldvalue.encode('utf-8'), newvalue.encode('ut...
def addAttachment(self, id, attachment, description, author): print 'inserting attachment for ticket %s -- %s' % (id, description) attachment.filename = attachment.filename.encode('utf-8') self.env.create_attachment(self.db(), 'ticket', str(id), attachment, description.encode('utf-8'), author, 'unknown')
def addAttachment(self, author, a): description = a['description'].encode('utf-8') id = a['bug_id'] filename = a['filename'].encode('utf-8') filedata = StringIO.StringIO(a['thedata'].tostring()) filesize = len(filedata.getvalue()) time = a['creation_ts'] print " ->inserting attachment '%s' for ticket %s -- %s" % \ (...
def addAttachment(self, id, attachment, description, author): print 'inserting attachment for ticket %s -- %s' % (id, description) attachment.filename = attachment.filename.encode('utf-8') self.env.create_attachment(self.db(), 'ticket', str(id), attachment, description.encode('utf-8'), author, 'unknown')
cursor.execute("SELECT * FROM profiles WHERE userid = %s" % userid)
cursor.execute("SELECT * FROM profiles WHERE userid = %s", (userid))
def getLoginName(self, cursor, userid): if userid not in self.loginNameCache: cursor.execute("SELECT * FROM profiles WHERE userid = %s" % userid) loginName = cursor.fetchall()
print 'warning: unknown bugzilla userid %d, recording as anonymous' % userid loginName = 'anonymous'
print """WARNING: unknown bugzilla userid %d, recording as anonymous""" % (userid) loginName = "anonymous" loginName = LOGIN_MAP.get(loginName, loginName)
def getLoginName(self, cursor, userid): if userid not in self.loginNameCache: cursor.execute("SELECT * FROM profiles WHERE userid = %s" % userid) loginName = cursor.fetchall()
cursor.execute("SELECT * FROM fielddefs WHERE fieldid = %s" % fieldid)
cursor.execute("SELECT * FROM fielddefs WHERE fieldid = %s", (fieldid))
def getFieldName(self, cursor, fieldid): if fieldid not in self.fieldNameCache: cursor.execute("SELECT * FROM fielddefs WHERE fieldid = %s" % fieldid) fieldName = cursor.fetchall()
print 'warning: unknown bugzilla fieldid %d, recording as unknown' % userid fieldName = 'unknown'
print "WARNING: unknown bugzilla fieldid %d, \ recording as unknown" % (userid) fieldName = "unknown"
def getFieldName(self, cursor, fieldid): if fieldid not in self.fieldNameCache: cursor.execute("SELECT * FROM fielddefs WHERE fieldid = %s" % fieldid) fieldName = cursor.fetchall()
def productFilter(fieldName, products): first = True result = '' for product in products: if not first: result += " or " first = False result += "%s = '%s'" % (fieldName, product) return result
def makeWhereClause(fieldName, values, negative=False): if not values: return '' if negative: connector, op = ' AND ', '!=' else: connector, op = ' OR ', '=' clause = connector.join(["%s %s '%s'" % (fieldName, op, value) for value in values]) return ' ' + clause
def productFilter(fieldName, products): first = True result = '' for product in products: if not first: result += " or " first = False result += "%s = '%s'" % (fieldName, product) return result
if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue'
print "Using Bugzilla v%s schema." % BZ_VERSION if BZ_VERSION == 2110: activityFields['removed'] = "oldvalue" activityFields['added'] = "newvalue"
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
print "Bugzilla MySQL('%s':'%s':'%s':'%s'): connecting..." % (_db, _host, _user, _password)
print "Bugzilla MySQL('%s':'%s':'%s':'%s'): connecting..." % \ (_db, _host, _user, ("*" * len(_password)))
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
print "cleaning all tickets..."
print "\nCleaning all tickets..."
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
c.execute("""DELETE FROM ticket_change""")
c.execute("DELETE FROM ticket_change")
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
c.execute("""DELETE FROM ticket""")
c.execute("DELETE FROM ticket")
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
c.execute("""DELETE FROM attachment""") os.system('rm -rf %s' % trac.env.get_attachments_dir()) os.mkdir(trac.env.get_attachments_dir())
c.execute("DELETE FROM attachment") attachments_dir = os.path.join(os.path.normpath(trac.env.path), "attachments") for root, dirs, files in os.walk(attachments_dir, topdown=False): for name in files: os.remove(os.path.join(root, name)) for name in dirs: os.rmdir(os.path.join(root, name)) if not os.stat(attachments_dir...
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
print print "1. import severities..." severities = (('blocker', '1'), ('critical', '2'), ('major', '3'), ('normal', '4'), ('minor', '5'), ('trivial', '6'), ('enhancement', '7')) trac.setSeverityList(severities) print print "2. import components..." sql = "SELECT value, initialowner AS owner FROM components" if PRODUCT...
print "All tickets cleaned..." print "\n0. Filtering products..." mysql_cur.execute("SELECT name FROM products") products = [] for line in mysql_cur.fetchall(): product = line['name'] if PRODUCTS and product not in PRODUCTS: continue if product in IGNORE_PRODUCTS: continue products.append(product) PRODUCTS[:] = produ...
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...
print print "5. import milestones..." mysql_cur.execute("SELECT value FROM milestones")
print "\n5. Import milestones..." sql = "SELECT DISTINCT value FROM milestones" sql += " WHERE" + makeWhereClause('value', IGNORE_MILESTONES, negative=True) mysql_cur.execute(sql)
def convert(_db, _host, _user, _password, _env, _force): activityFields = FieldTranslator() # account for older versions of bugzilla if BZ_VERSION == '2.11': print 'Using Buzvilla v%s schema.' % BZ_VERSION activityFields['removed'] = 'oldvalue' activityFields['added'] = 'newvalue' # init Bugzilla environment print "B...