def main(session): args = parser.parse_args() problems = get_problems(session) teams = get_team_names(session) directory, target_files, problem_name = setup_submission( args.submission_id, problems, teams) if args.extract: paths = extract(directory, target_files) test_file = setup_testall(paths) else: paths = glob.glob(os.path.join(directory, '*.java')) paths = [p for p in paths if not p.endswith('/RunTestAll.java')] test_files = [ os.path.basename(path) for path in paths if any('testAll()' in line for line in open(path)) ] assert len(test_files) == 1, test_files test_file, = test_files print("Stored in %s" % directory) if directory: remove_package(paths) if args.patch: patch_test_file(directory, test_file, problem_name, args.override_version) if args.instrument: for path in paths: instrument(path) subprocess.check_call(['javac'] + glob.glob('%s/*.java' % directory)) subprocess.check_call(('java', '-cp', directory, 'RunTestAll'))
def __init__(self, name_pattern, directory, motor, start, end, speed, monitors=[], display=None, analysis=None): experiment.__init__(self, name_pattern=name_pattern, directory=directory, analysis=analysis) if type(motor) == str: try: self.motor = tango_motor(motor) except: print traceback.print_exc() else: self.motor = motor self.start = start self.end = end self.speed = speed self.instrument = instrument() self.monitors = monitors self.display = display
def get_instrument_configuration(self): '''the purpose of this method is to gather and return all relevant information about the beamline and the machine Information to collect: 0. machine status, current, mode 1. slit positions 2. tables positions 3. intensity monitor values 4. undulator settings 5. mirrors motors and tensions 6. pressure monitors 7. monochoromator motors 8. thermometers readings 9. diffractometer parameters 10. aperture settings ''' try: from instrument import instrument self.instrument = instrument() except ImportError: print 'Not possible to import instrument' return None return self.instrument.get_state()
def main(): filepath, port, graphic = evaluate_args() if graphic: initGUI(filepath, port) else: if '/' in filepath: shutil.copy(filepath, './') filename = filepath.split('/')[-1] else: filename = filepath source = filename.split('.')[0] + '.inst' # "arquivo.inst.c" functions = instrument.instrument( filename) # Instrumenta o código-fonte original make.run( source, port ) # Compila o código-fonte instrumentado e faz upload para o Arduino if '/' in filepath: os.remove(filename) monitor.monitor( functions, port ) # Inicia o 'live-profiling' do código instrumentado sendo executado no Arduino
def buildAndUpload(self): self.func_monitor = {} if self.usbPortInput.text() == '' or self.filepath == '': self.error_dialog = QErrorMessage(self) self.error_dialog.setShortcutEnabled(False) self.error_dialog.showMessage( 'You need to input the source file and the USB port.') else: self.errorLabel.setText("") self.startProfilingBtn.setDisabled(True) self.logOutput.setText('Instrumenting...') QApplication.processEvents() if '/' in self.filepath: shutil.copy(self.filepath, './') filename = self.filepath.split('/')[-1] else: filename = self.filepath self.port = self.usbPortInput.text() source = filename.split('.')[0] + '.inst' # "arquivo.inst.c" # Instrumenta o código-fonte original self.functions = instrument.instrument(filename) self.logOutput.setText('Compiling and uploading to Arduino...') QApplication.processEvents() # Compila o código-fonte instrumentado e faz upload para o Arduino ret = make.run(source, self.port) if 'Error' in ret[0] or 'Error' in ret[1]: self.errorLabel.setText( "Error while building or uploading to Arduino!") self.startProfilingBtn.setDisabled(True) QApplication.processEvents() else: self.startProfilingBtn.setDisabled(False) QApplication.processEvents() self.logOutput.setText(ret[0] + ret[1]) if '/' in self.filepath: os.remove(filename)
def __init__(self): self.time_stamp = time.time() self.instrument = instrument()
def main(): parser = argparse.ArgumentParser(description='Stats collector') parser.add_argument( 'filename', metavar='filename', type=str, nargs='+', help='filename or path to folder( pass -z if folder is PHP folder') parser.add_argument('-l', metavar='LOWER', type=int, nargs='?', help='lower limmit acceptable limit for expected') parser.add_argument('-u', metavar='UPPER', type=int, nargs='?', help='upper limmit acceptable limit for unexpected') parser.add_argument('-p', action='store_true', help='parse and build') parser.add_argument('-r', action='store_true', help='run the workload') parser.add_argument('-v', action='store_true', help='verbose') parser.add_argument( '-a', action='store_true', help='does parse, build and run(equivalent with -p -r)') parser.add_argument('-i', metavar='PATH_TO_INI_FILE', type=str, nargs='?', help='ini file path') args = parser.parse_args() collect_statistics.FILENAME = args.filename[0] constants.PATH_TO_SOURCES = args.filename[0] lower_limit = args.l upper_limit = args.u ini_path = args.i constants.Constants.PATH_TO_SOURCES = args.filename[0] if args.a: args.p = True args.r = True # sets lower and upper limit for EXPECTED/UNEXPECTED percentage if upper_limit != None: constants.Constants.EXPECTED_LIMIT = upper_limit collect_statistics.EXPECTED_LIMIT = upper_limit if lower_limit != None: constants.Constants.UNEXPECTED_LIMIT = lower_limit collect_statistics.UNEXPECTED_LIMIT = lower_limit # e if ini_path != None: constants.Constants.DEFAULT_INI_FILE = ini_path constants.Constants.IR = ini.IniReader( constants.Constants.DEFAULT_INI_FILE) constants.Constants.IR.read() constants.Constants.BR = blacklist.BlacklistReader( constants.Constants.IR.get_rule("Config.BLACKLIST")) constants.Constants.BR.read() constants.Constants.IR.to_string() # LIKELY and UNLIKELY contains the lists with all versions of macros # you use in code for _buildin_expected constants.Constants.LIKELY = constants.Constants.IR.get_rule( "Config.LIKELY").split(" ") constants.Constants.UNLIKELY = constants.Constants.IR.get_rule( "Config.UNLIKELY").split(" ") if '' in constants.Constants.LIKELY: constants.Constants.LIKELY.remove('') if '' in constants.Constants.UNLIKELY: constants.Constants.UNLIKELY.remove('') # edits and tags branches working_folder = constants.Constants.IR.get_rule( "Environment.WORKING_FOLDER") if working_folder.endswith("/") == False and os.path.isdir(working_folder): working_folder += "/" if not constants.Constants.PATH_TO_SOURCES.endswith("/") and os.path.isdir( constants.Constants.PATH_TO_SOURCES): constants.Constants.PATH_TO_SOURCES += "/" if os.path.exists(working_folder) and args.p: raise SystemError(working_folder + " exists." + " Remove or specify another path in ini file.") sources = constants.Constants.PATH_TO_SOURCES constants.Constants.PATH_TO_SOURCES = working_folder if args.p == True: print "\nwith -p\n" #create working folder and copy content in it command = "mkdir " + working_folder print command os.system(command) if os.path.isdir(sources): sources += "*" command = "cp -r " + sources + " " + working_folder print command os.system(command) # prepare script if constants.Constants.IR.get_rule( "Environment.PREPARE_SCRIPT").endswith(".py"): command = "python " \ + constants.Constants.IR.get_rule("Environment.PREPARE_SCRIPT") else: command = "./" + \ constants.Constants.IR.get_rule("Environment.PREPARE_SCRIPT") print command if args.v == False: command += " > /dev/null" os.system(command) print "Parse sources for isolating atomic conditions one per line ..." parse.start(constants.Constants.PATH_TO_SOURCES) # build/ compile the filename or # files contained in the filename(when it's a folder) # using with intstrument.py instrument.instrument(constants.Constants.PATH_TO_SOURCES, args.v, args.p, args.r) if args.r: # Generate csv file/s print "Aggregate CSV statistics ..." if os.path.isdir(constants.Constants.PATH_TO_SOURCES): generate_csv.apply_on_folder( os.path.join(constants.Constants.PATH_TO_SOURCES, "GCOVS")) else: generate_csv.generate(constants.Constants.PATH_TO_SOURCES + ".gcov") # handles the format of output collect_statistics.collect( os.path.join(constants.Constants.PATH_TO_SOURCES, "GCOVS/"))
def main(): wrongUnexp = False wrongExp = False right = False raw = False folder = False zend = False parser = argparse.ArgumentParser(description="Stats collector") parser.add_argument( "filename", metavar="filename", type=str, nargs="+", help="filename or path to folder( pass -z if folder is PHP folder", ) parser.add_argument("-l", metavar="LOWER", type=int, nargs="?", help="lower limmit acceptable limit for expected") parser.add_argument("-u", metavar="UPPER", type=int, nargs="?", help="upper limmit acceptable limit for unexpected") parser.add_argument("-F", action="store_true", help="apply on folder") parser.add_argument("-p", action="store_true", help="parse and build") parser.add_argument("-r", action="store_true", help="run the workload") parser.add_argument("-v", action="store_true", help="verbose") parser.add_argument("-a", action="store_true", help="does parse, build and run(equivalent with -p -r)") parser.add_argument("-d", metavar="PATH", type=str, nargs="?", help="PATH where we put the LCOV RESULTS") parser.add_argument("-i", metavar="PATH_TO_INI_FILE", type=str, nargs="?", help="ini file path") args = parser.parse_args() collect_statistics.FILENAME = args.filename[0] constants.PATH_TO_SOURCES = args.filename[0] lowerLimit = args.l upperLimit = args.u folder = args.F all = args.a lcovPath = args.d iniPath = args.i constants.Constants.PATH_TO_SOURCES = args.filename[0] if all: args.p = True args.r = True # sets lower and upper limit for EXPECTED/UNEXPECTED percentage if upperLimit != None: constants.Constants.EXPECTED_LIMIT = upperLimit collect_statistics.EXPECTED_LIMIT = upperLimit if lowerLimit != None: constants.Constants.UNEXPECTED_LIMIT = lowerLimit collect_statistics.UNEXPECTED_LIMIT = lowerLimit # e if iniPath != None: constants.Constants.DEFAULT_INI_FILE = iniPath constants.Constants.IR = ini.IniReader(constants.Constants.DEFAULT_INI_FILE) constants.Constants.IR.read() constants.Constants.BR = blacklist.BlacklistReader(constants.Constants.IR.get_rule("Config.BLACKLIST")) constants.Constants.BR.read() constants.Constants.IR.to_string() # LIKELY and UNLIKELY contains the lists with all versions of macros # you use in code for _buildin_expected constants.Constants.LIKELY = constants.Constants.IR.get_rule("Config.LIKELY").split(" ") constants.Constants.UNLIKELY = constants.Constants.IR.get_rule("Config.UNLIKELY").split(" ") if "" in constants.Constants.LIKELY: constants.Constants.LIKELY.remove("") if "" in constants.Constants.UNLIKELY: constants.Constants.UNLIKELY.remove("") """print constants.Constants.EXPECTED print "\n" print constants.Constants.UNEXPECTED """ """ edits and tags branches """ working_folder = constants.Constants.IR.get_rule("Environment.WORKING_FOLDER") if working_folder.endswith("/") == False and os.path.isdir(working_folder): working_folder += "/" if constants.Constants.PATH_TO_SOURCES.endswith("/") == False and os.path.isdir( constants.Constants.PATH_TO_SOURCES ): constants.Constants.PATH_TO_SOURCES += "/" if os.path.exists(working_folder) and args.p: raise SystemError(working_folder + " exists." + " Remove or specify another path in ini file.") sources = constants.Constants.PATH_TO_SOURCES constants.Constants.PATH_TO_SOURCES = working_folder if args.p == True: print "\nwith -p\n" """ create working folder and copy content in it """ command = "mkdir " + working_folder print command os.system(command) if os.path.isdir(sources): sources += "*" command = "cp -r " + sources + " " + working_folder print command os.system(command) """ prepare script """ if constants.Constants.IR.get_rule("Environment.PREPARE_SCRIPT").endswith(".py"): command = "python " + constants.Constants.IR.get_rule("Environment.PREPARE_SCRIPT") else: command = "./" + constants.Constants.IR.get_rule("Environment.PREPARE_SCRIPT") print command if args.v == False: command += " > /dev/null" os.system(command) print "Parse sources for isolating atomic conditions one per line ..." parse.start(constants.Constants.PATH_TO_SOURCES) """ build/ compile the filename or files contained in the filename(when it's a folder) using with intstrument.py """ instrument.instrument(constants.Constants.PATH_TO_SOURCES, lcovPath, args.v, args.p, args.r) if args.r: """ Generate csv file/s """ # print filename # print os.system("ls ") print "Aggregate CSV statistics ..." if os.path.isdir(constants.Constants.PATH_TO_SOURCES): generate_csv.apply_on_folder(os.path.join(constants.Constants.PATH_TO_SOURCES, "GCOVS")) else: generate_csv.generate(constants.Constants.PATH_TO_SOURCES + ".gcov") """ handles the format of output """ collect_statistics.collect(os.path.join(constants.Constants.PATH_TO_SOURCES, "GCOVS/"))
from instrument import instrument trombone = instrument("tromboneSounds.txt") trombone.action(3) trombone.action(1) trombone.action(3) trombone.action(2) trombone.action(3)
from instrument import instrument t = instrument() t.queue_sound(493, 1) t.queue_sound(440, 1) t.queue_sound(392, 1) t.queue_sound(0, 1) t.queue_sound(493, 1) t.queue_sound(440, 1) t.queue_sound(392, 1) t.queue_sound(0, 1) t.queue_sound(392, 0.5) t.queue_sound(392, 0.5) t.queue_sound(392, 0.5) t.queue_sound(392, 0.5) t.queue_sound(440, 0.5) t.queue_sound(440, 0.5) t.queue_sound(440, 0.5) t.queue_sound(440, 0.5) t.queue_sound(0, 1) t.queue_sound(493, 1) t.queue_sound(440, 1) t.queue_sound(392, 1)