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 __call__(self): # TODO: Exception safety self.log.write('updating from repository... ') starttime = datetime.datetime.now() git.reset(self.revision) timedelta = datetime.datetime.now() - starttime self.log.write('done. (took ' + str(total_seconds(timedelta)) + 's) \n') # Build the documentation self.log.write('building docs... ') starttime = datetime.datetime.now() make.make('docs') make.run('docs') timedelta = datetime.datetime.now() - starttime self.log.write('done. (took ' + str(total_seconds(timedelta)) + 's) \n') git.reset('master') # Revert possible modifications to .po files username = '******' passwd = open('../passwd/docs.txt', 'r').read().strip() ftphost = FTPHostFix.connect('ftp.openclonk.org', user=username, password=passwd) # upload to /new self.log.write('uploading new docs... \n') starttime = datetime.datetime.now() self.__upload_new_files(ftphost) timedelta = datetime.datetime.now() - starttime self.log.write('done. (took ' + str(total_seconds(timedelta)) + 's) \n') # copy script files over to /new self.log.write('copying script files... \n') starttime = datetime.datetime.now() self.__copy_old_script_files(ftphost) timedelta = datetime.datetime.now() - starttime self.log.write('done. (took ' + str(total_seconds(timedelta)) + 's) \n') # move everything in / to /old (except just uploaded new directory) # move everything in /new to / self.log.write('replacing docs... ') self.__replace_files(ftphost) self.log.write('done. \n') # at this point, the new version is online. # delete /old folder # walk reverse cause the bottom-most folders need to be deleted first self.log.write('deleting old docs... \n') starttime = datetime.datetime.now() self.__remove_old_files(ftphost) timedelta = datetime.datetime.now() - starttime self.log.write('done. (took ' + str(total_seconds(timedelta)) + 's) \n') return True
def test_should_fail_execution(self): def task1(): raise Exception("AHHH!!") self.module.task1 = task1 with self.assertRaises(Exception) as cm: make.run(self.module, ['task1'], self.fake_cprint) self.assertEqual(cm.exception.message, 'AHHH!!') self.assertEqual(self.get_out_lines(), [ 'Executing task1', 'Make Failed!', ])
def test_should_execute_normally(self): executed_tasks = [] self.module.task1 = lambda: executed_tasks.append('task1') self.module.task2 = lambda: executed_tasks.append('task2') make.run(self.module, ['task1', 'task2', 'o1=v1', 'o2=v2'], self.fake_cprint) self.assertEqual(executed_tasks, ['task1', 'task2']) self.assertEqual('v1', self.module.o1) self.assertEqual('v2', self.module.o2) self.assertEqual(self.get_out_lines(), [ 'o1: v1', 'o2: v2', 'Executing task1', 'Executing task2', 'Make Succeeded!', ])
def test(arg='', *args): if not arg: return run('help', 'test') elif arg == 'unit': test_unit(*args) elif arg in ('style', 'flake', 'flake8'): test_style(*args) elif arg in ('cover', 'coverage'): show_coverage_html(*args) else: sys.exit('invalid test mode %r' % arg)
def test(arg="", *args): if not arg: return run("help", "test") elif arg == "unit": test_unit(*args) elif arg in ("style", "flake", "flake8"): test_style(*args) elif arg in ("cover", "coverage"): show_coverage_html(*args) else: sys.exit("invalid test mode %r" % arg)
def docs(arg=''): # Prepare if not arg: return run('help', 'docs') # Go if 'html' == arg: sphinx_clean(DOC_BUILD_DIR) sphinx_build(DOC_DIR, DOC_BUILD_DIR) elif 'show' == arg: sphinx_show(os.path.join(DOC_BUILD_DIR, 'html')) else: sys.exit('Command "docs" does not have subcommand "%s"' % arg)
def test_should_keep_exception_traceback(self): # https://ironpython.codeplex.com/workitem/34386 def task3(): return (1, 2) + [3, 4] # The unexpected behavior happen with this TypeError def task2(): task3() def task1(): task2() self.module.task3 = task3 self.module.task2 = task2 self.module.task1 = task1 try: make.run(self.module, ['task1'], self.fake_cprint) self.fail() except: exc_type, exc_value, exc_traceback = sys.exc_info() methods = [function_name for filename, line_number, function_name, text in traceback.extract_tb(exc_traceback)] self.assertEqual(methods, ['test_should_keep_exception_traceback', 'run', 'task1', 'task2', 'task3'])
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)