def cmd(self, args): """ Send cleartool command. setview ... endview ... ls ... """ if not isinstance(args, dict): return False args = {k: v[0] if isinstance(v, list) else v for k, v in args.iteritems()} if not args.has_key('command') or not isinstance(args['command'], str): return False if args['command'] == 'exit': print('Clearcase Plugin Srv: Shutting down...') cherrypy.engine.exit() elif args['command'].startswith('setview'): print('Clearcase Plugin Srv: Changing view: `{}`.'.format(args['command'])) _r = cleartool.cmd(args['command']) response = { 'status': _r[0], 'data': _r[1], 'error': _r[2], } return json.dumps(response)
def getTestDescription(self, user, fname): """ Returns the title, description and all tags from a test file. """ try: text = open(fname,'rb').read() except: return '' li_tags = re.findall('^[ ]*?[#]*?[ ]*?<(?P<tag>\w+)>([ -~\n]+?)</(?P=tag)>', text, re.MULTILINE) tags = '<br>\n'.join(['<b>' + title + '</b> : ' + descr.replace('<', '<') for title, descr in li_tags]) data = cleartool.cmd( 'ls {}'.format(fname) )[1] if data: data = data.split()[0].split('@@')[1] extra_info = '<b>ClearCase Version</b> : {}'.format(data) return tags + '<br>\n' + extra_info