obj['modified'] = str(modification_date(obj['path'])).strip('\'') children = [] if os.path.isdir(obj['path']): for o in os.listdir(obj['path']): if os.path.isdir(os.path.join(obj['path'], o)): full_path = os.path.join(obj['path'], o) path_arr = full_path.split('/') pts = path_arr[len(path_arr)-1] children.append(generate_file_object(pts, obj['path'])) else: children.append(o) obj['children'] = children except Exception,e: log.exception('modification_date: Exception. %s' % e) raise log.info('Exiting: modification_date') return obj def get_global_vars(): features = [] return {'build_number': '', 'ui_log_level': '', 'features': ''} class IxiaJsonLoader(object):
data = self.request.json_body type = data['type'] if 'type' in data else 'Undefined' method = type.lower() try: method = getattr(uilogger, method) except AttributeError, e: # Trying to log an error with unsupported type, default to error method = uilogger.error message = data['message'] + ' ' if 'message' in data else '' method(message + dumps(data, indent=4)) return {'result': 'SUCCESS'} except Exception, e: ixiacrlogger.exception('%s' % e) return {'result': 'FAILURE: %s' % e} finally: ixiacrlogger.debug('Exiting: log_js') @action(renderer='json') def update_user_timestamp(self): ixiacrlogger.debug('Entering: update_user_timestamp') #ixiacrlogger.info(str(self.request.cookies)) #ixiacrlogger.info(str(self.request.cookies.get('auth_tkt'))) self.messages = [] ixiacrlogger.debug(str(self.request.cookies.get('auth_tkt').split('!')[0])) try: user = User.by_id(self.user_id) if user:
class ResultsConsumer(object): RESULT_SYNC_TRIGGERS = [ ResultPacket.ResultType.TestStop, ResultPacket.ResultType.ResultSetStop ] def __init__(self): db.configure(bind=create_engine( 'sqlite:///%(here)s/cyberrange.sqlite')) self.rr = results.ResultReader() self.log = IxiaLogger(__name__) self.log.debug('ResultsConsumer: initialized') self._test_result_id = None self._test_config_obj = None self._results = list() @property def current_config(self): return None def _sync_results(self): ''' Process all of the accumulated results in one swell foop. ''' config = self.current_config start = time.time() with transaction.manager: sp = transaction.savepoint() for count, result in enumerate(self._results): if not config.test.process_result_transactionless( config, result.__dict__, config.result_id, db): self.log.error('ResultsConsumer: Processing failed for {0}. ' 'Rolling back to last savepoint.'.format(result)) sp.rollback() break stop = time.time() fargs = { 'count': count, 'time': stop - start, 'avg': (stop - start) / float(count) if count > 0 else 0 } self.log.debug('ResultsConsumer: Processed {count} results in {time:.3f} seconds ' '({avg:.3f} seconds/result)'.format(**fargs)) self._results = list() def process_result(self, ch, method, properties, body): ''' The result data consumer callback that processes results into the data object being passed in from the task consumer. ''' try: result = cPickle.loads(body) assert result, 'Unable to unpickle result object' self._results.append(result) if result.resulttype in self.RESULT_SYNC_TRIGGERS: self._sync_results() return True except Exception as e: self.log.exception('ResultsConsumer: {0}'.format(e)) return False def run(self): self.rr.read(self.process_result)
except Exception, e: msg = ('run_test: bpsFile={0}; e={1}' .format(file, str(e))) ixiacrlogger.exception(msg) self.updateTestResults(result_id, end_result='FINISHED') return {'is_ready': True, 'is_valid': True, 'items': [], 'test_result_id': result_id, 'messages': messages} except Exception, e: msg = ('run_test: ixiacr_test_id={0}; e={1}' .format(data['id'], str(e))) ixiacrlogger.exception(msg) self.updateTestResults(result_id, end_result='ERROR', error_reason=str(e)) msg_header, msg_content = str(e) messages.append({ 'header': self.localizer.translate(_(msg_header)), 'content': self.localizer.translate(_(msg_content)), 'is_error': True}) self.updateTestResults(result_id, end_result='ERROR') return self.fail(self.messages) @action(renderer='json') def check_for_conflicts_with_upcoming(self):