def program(): a = ProgramFinder() a.request a.extract_program() file = FileSystem("program.txt", a.get_programs()) file.writing() print "finished"
def test(): c = Crawler("http://www.artsandscience.utoronto.ca/ofr/timetable/winter/csc.html") c.extract_course_code() c.course_init() file = FileSystem("course.txt", c.get_courses()) file.writing() print "finished"
def removeRepoConfigDirectory(strWorkingCopyPath): if os.path.isfile(strWorkingCopyPath): strWorkingCopyPath = os.path.dirname(strWorkingCopyPath) strDirToDelete = os.path.join(strWorkingCopyPath, ".repo/") logger.info("Deleting %s" % strDirToDelete) FileSystem.deleteDir(strDirToDelete)
def main(): logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', datefmt='%d.%m.%y %H:%M:%S', filename='SyncCFT.log', filemode='w') console = logging.StreamHandler() #console.setLevel(logging.DEBUG) console.setLevel(logging.WARNING) formatter = logging.Formatter('%(levelname)s: %(name)s: %(message)s') console.setFormatter(formatter) logging.getLogger('').addHandler(console) logger = logging.getLogger("Test main in SignalConnection") config = Configuration(sys.argv) conf_values = config.load_configuration() if not conf_values: logger.error("An error occurred while loading the configuration!") return (port, folder, p_prob, q_prob, peers, passwd) = conf_values if passwd == '': use_enc = False else: use_enc = True #Logging of configuration logger.info("Listening on UDP port %s" % (str(port))) logger.info("'p' parameter: %s" % (str(p_prob))) logger.info("'q' parameter: %s" % (str(q_prob))) logger.info("Peers to connect:") for peer in peers: logger.info("%s, %s" % (peer[0], peer[1])) fsystem = FileSystem(folder, '.private') fsystem.start_thread() # Sleep a while, so we have an up-to-date manifest TODO Not sure manifest is done. time.sleep(2) dataserver = DataServer(fsystem.root_path,'0.0.0.0',int(port)+1, use_enc = use_enc, p = p_prob, q = q_prob) dataserver.start() #dataserver.add_port() server = SignalServer(fsystem = fsystem, dataserver = dataserver, port = int(port), sender_id = random.randint(0, 65535), q = q_prob, p = p_prob, passwd = passwd) server.init_connections(peers) server.start() while server.isAlive(): try: server.join(1) except KeyboardInterrupt: logger.info('CTRL+C received, killing server...') server.stop() dataserver.kill_server() fsystem.terminate_thread() logger.info('Stopping...')
def insertBinaries(filePath): ext = fs.getExtension(filePath) size = fs.getFileSize(filePath) fileName = fs.getFileName(filePath) filePath = filePath.replace("\\", "/") filePath = filePath.replace("'", "''") hexa = bin2hex(filePath) sql = Text.format(INSERT, fileName, filePath, ext, hexa, size) client = mysql.MySQL() client.execute(sql) return
def __init__(self, gametype, pgui): self.gui = pgui self.filesystem = FileSystem() self.iohandler = IOHandler(gametype, pgui) self.mapmanager = MapManager(self.filesystem.getData('map')) self.mapmanager.getVisibleObjects() self.messagehandler = MessageHandler( self.filesystem.getData("messages")) self.gamerun = False self.securitycamera = True self.talked = False
def generateConfig(self, asyncConfigPath=None, asyncConfigFileName=None): outIncludeDir = os.path.join(FileSystem.getDirectory(FileSystem.OUT_ROOT), "include") projectLogDir = FileSystem.getDirectory(FileSystem.LOG_DIR, self._config, self._project_name) asyncConfig = None if asyncConfigPath is None: asyncConfig = os.path.join(FileSystem.getDirectory(FileSystem.CLIENT_CONFIG), (asyncConfigFileName if asyncConfigFileName is not None else "AsyncConfig.xml")) else: asyncConfig = asyncConfigPath Utilities.mkdir(outIncludeDir) configArgs = [] configArgs.append(['std::string', 'LOGGING_ROOT', 'dir', projectLogDir.replace("\\", "/")]) if "Robos" in self._project_name: configArgs.append(['std::string', 'ASYNC_CONFIG_PATH', 'file', asyncConfig.replace("\\", "/")]) (formattedConfigArgsHeader, formattedConfigArgsSrc) = self.checkConfigArgsAndFormat("\t", configArgs) if os.path.exists(projectLogDir): Utilities.rmTree(projectLogDir) Utilities.mkdir(projectLogDir) projNameUpper = self._project_name.upper() with open(os.path.join(outIncludeDir, self._project_name + "Config.hpp"), 'w') as file: file.write("#pragma once\n" "#ifndef " + projNameUpper + "_CONFIG_" + projNameUpper + "CONFIG_HPP\n" "#define " + projNameUpper + "_CONFIG_" + projNameUpper + "CONFIG_HPP\n\n" "// SYSTEM INCLUDES\n" "#include <string>\n\n" "// C++ PROJECT INCLUDES\n\n" "namespace " + self._project_name + "\n" "{\n" "namespace Config\n" "{\n\n" + formattedConfigArgsHeader + "} // end of namespace Config\n" "} // end of namespace " + self._project_name + "\n" "#endif // end of " + projNameUpper + "_CONFIG_" + projNameUpper + "CONFIG_HPP\n") with open(os.path.join(outIncludeDir, self._project_name + "Config.cpp"), 'w') as file: file.write("// SYSTEM INCLUDES\n\n" "// C++ PROJECT INCLUDES\n" "#include \"" + self._project_name + "Config.hpp\"\n\n" "namespace " + self._project_name + "\n" "{\n" "namespace Config\n" "{\n\n" + formattedConfigArgsSrc + "} // end of namespace Config\n" "} // end of namespace " + self._project_name + "\n")
def __init__(self, fullpath, workingfolder): filename_arr = fullpath.split(os.sep) self.rootfolder = workingfolder self.fullfilename = fullpath self.filename = filename_arr[-1] self.extension = fs.FileExt(fullpath) self.folder = os.sep.join(filename_arr[:-1]) self.excludefilereorg = fn.ExcludeInFileReorg(self.fullfilename) self.isatroot = self.rootfolder == self.folder if self.isatroot: return parent_arr = fullpath.replace(workingfolder, "").split(os.sep) self.parentfoldername = [s for s in parent_arr if len(s) > 0][0] workingfolderArr = [ s for s in workingfolder.split(os.sep) if len(s) > 0 ] workingfolderArr.append(self.parentfoldername) self.parentfolderpath = os.sep.join(workingfolderArr)
def moveDependentProjectsToWorkingDir(self, projectToCopyFrom, projectType, rootToCopyFrom): destinationDir = FileSystem.getDirectory(FileSystem.INSTALL_ROOT, self._config, self._project_name) destLibDir = os.path.join(destinationDir, "lib") if not os.path.exists(destLibDir): Utilities.mkdir(destLibDir) if platform.system() == "Windows": destBinDir = os.path.join(destinationDir, "bin") if not os.path.exists(destBinDir): Utilities.mkdir(destBinDir) # copy dll and lib if projectType is None or projectType.upper() == "SHARED": Utilities.copyTree(os.path.join(rootToCopyFrom, "bin", projectToCopyFrom + ".dll"), destBinDir) Utilities.copyTree(os.path.join(rootToCopyFrom, "lib", projectToCopyFrom + ".lib"), destLibDir) else: if projectType is None or projectType.upper() == "SHARED": # copy .so baseRoot = os.path.join(rootToCopyFrom, "lib") if not os.path.exists(baseRoot): baseRoot = os.path.join(rootToCopyFrom, "lib64") if not os.path.exists(baseRoot): Utilities.failExecution("directories [%s, %s] do not exist" % (os.path.join(rootToCopyFrom, "lib"), baseRoot)) fileRegex = "lib" + projectToCopyFrom currentFilePath = None for entry in os.listdir(baseRoot): currentFilePath = os.path.join(baseRoot, entry) if fileRegex in entry and not os.path.isdir(currentFilePath): Utilities.copyTree(currentFilePath, destLibDir) else: # copy .a Utilities.copyTree(os.path.join(rootToCopyFrom, "lib", "lib" + projectToCopyFrom + ".a"), destLibDir) Utilities.copyTree(os.path.join(rootToCopyFrom, "include", projectToCopyFrom), os.path.join(destinationDir, "include", projectToCopyFrom))
def parseDependencyFile(self): dependencyFilePath = os.path.join(FileSystem.getDirectory(FileSystem.DEPENDENCIES), "dependencies.txt") if not os.path.exists(dependencyFilePath): Utilities.failExecution("dependency file [%s] does not exist" % dependencyFilePath) requiredProjects = [] with open(dependencyFilePath, 'r') as file: flag = False lineNum = 0 splitLine = None for line in file: splitLine = line.strip().split(None) if len(splitLine) == 0 or splitLine[0] == '#': continue if splitLine[0] == '-' + self._project_name: flag = True elif flag and '-' not in splitLine[0]: requiredProjects.append(splitLine) elif flag and '-' in splitLine[0] and ('-' + self._project_name) != splitLine[0]: flag = False elif not flag: continue else: Utilities.failExecution("Parse error in dependency file [%s] at line [%s]" % (dependencyFilePath, lineNum)) lineNum += 1 print("Required projects for project [%s] are %s" % (self._project_name, requiredProjects)) return requiredProjects
def updateBinaries(id, filePath): ext = fs.getExtension(filePath) hexa = bin2hex(filePath) sql = Text.format(UPDATE, id, ext, filePath, hexa) client = mysql.MySQL() client.execute(sql) return
def makeTarget(self, targets): # make directory that CMake will dump all output to wd = FileSystem.getDirectory(FileSystem.WORKING, self._config, self._project_name) if platform.system() == "Windows": Utilities.PForkWithVisualStudio(appToExecute="nmake", argsForApp=targets, wd=wd) else: Utilities.PFork(appToExecute="make", argsForApp=targets, wd=wd, failOnError=True)
def makeVisualStudioProjects(self, test="OFF", logging="OFF"): wd = FileSystem.getDirectory(FileSystem.VISUAL_STUDIO_ROOT, self._config, self._project_name) Utilities.mkdir(wd) CMakeArgs = self.getCMakeArgs("", wd, test, logging) if platform.system() == "Windows": visualStudioVersion = Utilities.formatVisualStudioVersion(Utilities.getVisualStudioVersion()) CMakeArgs.extend(["-G", '"Visual Studio %s"' % visualStudioVersion]) Utilities.PForkWithVisualStudio(appToExecute="cmake", argsForApp=CMakeArgs, wd=wd)
def buildAndLoadDependencies(self): dependentProjects = self.parseDependencyFile() print("dependentProjects %s" % dependentProjects) projectBuild = None Utilities.mkdir(FileSystem.getDirectory(FileSystem.INSTALL_ROOT, self._config, self._project_name)) allBuiltOutDir = FileSystem.getDirectory(FileSystem.OUT_ROOT, self._config) for project in dependentProjects: dependentProjectPath = FileSystem.getDirectory(FileSystem.INSTALL_ROOT, self._config, project[0]) # build the project if necessary if not os.path.exists(dependentProjectPath): projectBuild = LocalBuildRules.LocalBuild(project[0]) projectBuild.run(([], self._custom_args)) # copy over necessary objects to link self.moveDependentProjectsToWorkingDir(project[0], project[1] if len(project) >= 2 else None, allBuiltOutDir)
def cmake(self, test="OFF", logging="OFF", python="OFF"): # make directory that CMake will dump output to wd = FileSystem.getDirectory(FileSystem.WORKING, self._config, self._project_name) Utilities.mkdir(wd) CMakeArgs = self.getCMakeArgs("", wd, test, logging, python) if platform.system() == "Windows": CMakeArgs.extend(["-G", '"NMake Makefiles"']) Utilities.PForkWithVisualStudio(appToExecute="cmake", argsForApp=CMakeArgs, wd=wd) else: CMakeArgs.extend(["-G", "Unix Makefiles"]) Utilities.PFork(appToExecute="cmake", argsForApp=CMakeArgs, wd=wd, failOnError=True)
def DeleteUnwatedFiles(workingdir): allfiles = list(fs.GetAllFiles(workingdir)) # delete unwanted files for file in allfiles: fileinfo = FileInfo(file, workingdir) # if contact sheet if (fileinfo.extension == conf.contact_ext): # make sure matching video file exists if not CorrespondingVideoFileExists(fs.FileNameOnly(file), conf.video_ext, allfiles): # if no matching video file, delete fs.DeleteFile(file) # if is not contact sheet or video file, delete elif (fileinfo.extension not in conf.video_ext) or ('sample' in fileinfo.filename.lower()): fs.DeleteFile(file)
def RenameMove(workingdir): # rename video file name and move to parent allfiles = list(fs.GetAllFiles(workingdir)) # move video files to working folder root for file in allfiles: # object to parse out file path parts fileinfo = FileInfo(file, workingdir) # skip file is not video or marked for omit reorg if (fileinfo.extension not in conf.video_ext) \ or fileinfo.isatroot \ or fileinfo.excludefilereorg: continue # unique counter iterator = 0 newfilename = os.path.join(fileinfo.rootfolder, fileinfo.parentfoldername) \ + fileinfo.extension # make filename unique if exists in destination while os.path.isfile(newfilename): newfilename = os.path.join(fileinfo.rootfolder, fileinfo.parentfoldername) + "-" + \ ("%02d" % (iterator,)) + fileinfo.extension iterator += 1 # move / rename file to parent root dir fs.Movefile(fileinfo.fullfilename, newfilename) # delete subdirs # get first level subdirs subdirs = next(os.walk(workingdir))[1] # delete dir is not omit reorg for dir in subdirs: if not ExcludeInFileReorg(dir): shutil.rmtree(os.path.join(workingdir, dir))
def generateProjectVersion(self): outIncludeDir = os.path.join( FileSystem.getDirectory(FileSystem.OUT_ROOT), 'include' ) print("making directory %s" % outIncludeDir) Utilities.mkdir(outIncludeDir) with open(os.path.join(outIncludeDir, 'Version.hpp'), 'w') as file: file.write("#pragma once\n" "#ifndef VERSION_H\n" "#define VERSION_H\n\n" "#define VERSION " + self._project_build_number + "\n" "#define VERSION_STR \"" + self._project_build_number + "\"\n\n" "#endif // VERSION_H\n\n")
def __init__(self): self._project_name = "" self._project_namespace = "" self._source_dirs = ["cpp"] self._build_steps = [] self._project_build_number = "0.0.0.0" self._configurations = ["debug", "release"] self._build_directory = FileSystem.getDirectory(FileSystem.WORKING) # execute local environment projectSpecificEnvVars = { # project specific static environment variables } localEnv = LocalEnvironment.LocalEnvironment(projectSpecificEnvVars) localEnv.injectAllEnvironmentVariables()
def itemFileSystem(self): self.item_fs = QtWidgets.QWidget() layout = QtWidgets.QVBoxLayout() self.item_fs.setLayout(layout) # instance of QFileSystemModel filesystem_model = FileSystem.FileSystemModel() root_path = filesystem_model.rootPath() self.tree = QtWidgets.QTreeView() self.tree.setModel(filesystem_model) self.tree.setRootIndex(filesystem_model.index(root_path)) self.tree.setAnimated(True) # hide size column self.tree.setColumnHidden(1, True) # hide type column self.tree.setColumnHidden(2, True) # hide date modified column self.tree.setColumnHidden(3, True) # hide the header line of the filesystem tree # the header line would consist of name, date, type, size # the latter three are hidden anyway (see above) header = self.tree.header() header.hide() # handler self.tree.clicked.connect(filesystem_model.onFileSelected) self.tree.doubleClicked.connect(filesystem_model.onFileLoad) layout.addWidget(self.tree, stretch=12) # layout.setAlignment(QtCore.Qt.AlignTop) self.header = QtWidgets.QLabel('Loaded airfoil(s)') self.header.setEnabled(False) layout.addStretch(stretch=2) layout.addWidget(self.header) self.listwidget = ListWidget(self.parent) self.listwidget.setEnabled(False) # allow only single selections self.listwidget.setSelectionMode( QtWidgets.QAbstractItemView.SingleSelection) layout.addWidget(self.listwidget, stretch=5) layout.addStretch(stretch=1)
def launch_client(response_record, data_path, M): """ launch client for different uses :param data_path: directory of the client :param M: file size in storage node """ client = fs.Clients(data_path, fs.DirectoryServerPortBase + 1) #CONNECT TEST: get location of storage nodes client.connect() start = time.time() fl = utils.get_file_list(data_path) #ADDFILE TEST: add local files to file system rn = random.randint(0, len(fl) - 1) filename = fl[rn] task_log['add'].append(filename) print("Client on {0} adding file: {1}".format(data_path, filename)) path = data_path + filename file = utils.obtain(path) if len(file) < 5: print("*" * 21 + path + "*" * 21 + ":" + file + "\n") client.addFile(filename, file) #GET_FILE_LIST test: get file list from directory and storage nodes file_list_dir = client.get_FileList(isDir=True) if len(file_list_dir) > M: file_list_dir = file_list_dir[:M] print("File list from directory server: {}".format(file_list_dir)) if len(file_list_dir) == 0: return # tasks = [filename not in fl for filename in file_list_dir] tasks = file_list_dir rn = random.randint(0, len(tasks) - 1) task = tasks[rn] task_log['get'].append(task) print("Client on {0} downloading: {1}".format(data_path, task)) client.readFile(task) end = time.time() response_time = end - start print("\nRequests in {0} of finished in {1:4f} second\n".format( data_path, response_time)) accu, count = response_record[data_path] accu += response_time count += 3 response_record[data_path] = accu, count
def run_storage(configs): """ run storage nodes :param configs: a list of (data_path, port) configs for storage servers :return storage_servers: a list of storage server objects for later manipulation :return threads: a list of threads launched by the function (running storage servers) """ storage_servers = [] threads = [] for path, port in configs: ss = fs.StorageServer(path, port) storage_servers.append(ss) for ss in storage_servers: i_thread = threading.Thread(target=launch_storage, args=(ss, )) i_thread.daemon = True i_thread.start() threads.append(i_thread) return storage_servers, threads
def Initialize(): print "Number of Data Servers : ", config.NUM_OF_SERVERS delay = 0 try: delay = int(raw_input("Enter delay value : ")) except Exception as err: print err print "Delay defaulted to ", delay config.SLEEP_TIME = delay while (True): try: startpoint = raw_input( "Please enter 4 digit starting port number : ") if len(startpoint) == 4: config.SERVER_PORT_BEGIN = int(startpoint) raw_input("Press enter after starting the servers : ") FileSystem.Initialize_My_FileSystem() break print("The length is not 4!") except ValueError: print("That's not an Integer!") return
def main(): # Make socket transport = TSocket.TSocket('localhost', 9090) # Buffering is critical. Raw sockets are very slow transport = TTransport.TBufferedTransport(transport) # Wrap in a protocol protocol = TBinaryProtocol.TBinaryProtocol(transport) # Create a client to use the protocol encoder client = FileSystem.Client(protocol) # Connect! transport.open() path = "/Users/bing/Desktop/IDEAP/thrift-start-learning/Src/com/cimon/SimpleFileSystem" filePath = "/Users/bing/Desktop/IDEAP/thrift-start-learning/Src/com/cimon/SimpleFileSystem/StorageFile" print(client.cat(path + "/FileSystem.thrift", Mode.TXT)) transport.close()
def runUnitTests(self, iterations=1, test="OFF", valgrind="OFF"): print("Running unit tests for project [%s]" % self._project_name) if test == "OFF": print("Unit tests disables for project [%s]" % self._project_name) return installRoot = FileSystem.getDirectory(FileSystem.INSTALL_ROOT, self._config, self._project_name) args = [] for iteration in range(0, int(iterations)): print("Running unit tests [%s/%s]" % (iteration + 1, iterations)) for testToRun in self._tests_to_run: executablePath = os.path.join(installRoot, "bin", testToRun) if platform.system() == "Windows": executablePath += ".exe" else: if valgrind == "ON": args = ['valgrind', '--leak-check=yes', executablePath] if os.path.exists(executablePath): Utilities.PFork(appToExecute=(executablePath if len(args) == 0 else None), argsForApp=args, failOnError=True) else: print("%s does NOT exist!" % executablePath) if iterations > 1: print("\n\n")
def main(): # set up programs program_finder = ProgramFinder("http://www.artsandscience.utoronto.ca/ofr/timetable/winter/") programs = program_finder.get_programs() program_file = FileSystem("programs.txt", programs) program_file.writing() print "Programs loaded" # set up user menu menu = {} index = 1 for program in programs: if programs[program].is_visible(): menu[index] = program index += 1 # Prompt user for selecting program and term for i in menu: print "{}: {}".format(i, menu[i]) in_code = input("Enter a program code: ") while int(in_code) not in menu: print("Invalid Program Code!") in_code = input("Enter a program code: ") term_code = raw_input('Enter F for searching Fall term, S for Winter: ') while term_code != 'F' and term_code != 'S': print("Invalid Term Code!") term_code = raw_input("Enter F for searching Fall term, S for Winter: ") program_name = menu[in_code] url = programs[program_name].get_url() spider = CourseFinder(url, term_code) course_file = FileSystem("course.txt", spider.get_courses()) course_file.writing() print "finished"
def getCMakeArgs(self, pathPrefix, workingDirectory, test, logging, python): CMakeProjectDir = "projects" relCMakeProjectDir = os.path.relpath(CMakeProjectDir, workingDirectory) dummyDir = os.path.join( FileSystem.getDirectory(FileSystem.OUT_ROOT, self._config, self._project_name), 'dummy') # projectWorkingDir = getDirectory(FileSystemDirectory.ROOT, self._config, self._project_name) installRootDir = FileSystem.getDirectory(FileSystem.INSTALL_ROOT, self._config, self._project_name) # all of these are relative paths that are used by CMake # to place the appropriate build components in the correct # directories. binDir = os.path.relpath( os.path.join(FileSystem.getDirectory(FileSystem.INSTALL_ROOT, self._config, self._project_name), "bin"), dummyDir ) libDir = os.path.relpath( os.path.join(FileSystem.getDirectory(FileSystem.INSTALL_ROOT, self._config, self._project_name), "lib"), dummyDir ) outIncludeDir = os.path.join(FileSystem.getDirectory(FileSystem.OUT_ROOT, self._config, self._project_name), "include") toolchainDir = os.path.relpath(FileSystem.getDirectory(FileSystem.CMAKE_TOOLCHAIN_DIR), workingDirectory) allBuiltOutDir = FileSystem.getDirectory(FileSystem.OUT_ROOT, self._config) if platform.system() == "Windows": installRootDir = "\"%s\"" % installRootDir.replace("\\", "/") outIncludeDir = "\"%s\"" % outIncludeDir.replace("\\", "/") # toolchain = "\"%s\"" % toolchainDir.replace("\\", "/") if self._config == "release": cmake_config = "Release" else: cmake_config = "Debug" fullToolchainPath = None if platform.system() == "Windows": fullToolchainPath = os.path.join(toolchainDir, "toolchain_windows_%s.cmake" % Utilities.getMachineBits()) # "x86") else: fullToolchainPath = os.path.join(toolchainDir, "toolchain_unix_%s.cmake" % Utilities.getMachineBits()) monoPath = os.environ.get("MONO_BASE_PATH").replace("\\", "/") \ if os.environ.get("MONO_BASE_PATH") is not None else "" pythonPath = os.environ.get("PYTHON_BASE_PATH").replace("\\", "/") \ if os.environ.get("PYTHON_BASE_PATH") is not None else "" pythonVer = os.environ.get("PYTHON_VERSION") if os.environ.get("PYTHON_VERSION") is not None else 0 # remember CMake paths need to be relative to the top level # directory that CMake is called (in this case projects/<project_name>) CMakeArgs = [ relCMakeProjectDir, "-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=%s%s" % (pathPrefix, binDir), "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=%s%s" % (pathPrefix, libDir), "-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=%s%s" % (pathPrefix, libDir), "-DCMAKE_PREFIX_PATH=%s" % (installRootDir), # absolute path "-DCMAKE_BUILD_TYPE=%s" % cmake_config, "-DPROCESSOR=%s" % Utilities.getProcessorInfo(), "-DCMAKE_TOOLCHAIN_FILE=%s" % fullToolchainPath, # toolchain file path (relative) "-DBUILD_%s=ON" % self._project_name.upper(), "-DCMAKE_INSTALL_PREFIX=%s" % allBuiltOutDir, # install root dir "-DRUN_UNIT_TESTS=%s" % test, "-DENABLE_LOGGING=%s" % logging, "-DMONO_PATH=\"%s\"" % monoPath, "-DPYTHON_PATH=\"%s\"" % pythonPath, "-DPYTHON_VERSION=%s" % pythonVer, "-DPYTHON_ENABLED=%s" % python, ] return CMakeArgs
def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, -1, title) monSysteme = FileSystem.FileManager() monBuilder = monSysteme.getBuilder() monBuilder.findRoots() p1 = TestPanel(self, monSysteme) #p1 = MyListCtrl(self, -1, monSysteme) #self.splitter = wx.SplitterWindow(self, ID_SPLITTER, style=wx.SP_BORDER) #self.splitter.SetMinimumPaneSize(50) #p1 = MyListCtrl(self.splitter, -1, monSysteme) #p2 = MyListCtrl(self.splitter, -1, monSysteme) #self.splitter.SplitVertically(p1, p2) self.Bind(wx.EVT_SIZE, self.OnSize) # self.Bind(wx.EVT_SPLITTER_DCLICK, self.OnDoubleClick, id=ID_SPLITTER) self.sb = self.CreateStatusBar() filemenu= wx.Menu() filemenu.Append(ID_EXIT,"E&xit"," Terminate the program") editmenu = wx.Menu() netmenu = wx.Menu() showmenu = wx.Menu() configmenu = wx.Menu() helpmenu = wx.Menu() menuBar = wx.MenuBar() menuBar.Append(filemenu,"&File") menuBar.Append(editmenu, "&Edit") menuBar.Append(netmenu, "&Net") menuBar.Append(showmenu, "&Show") menuBar.Append(configmenu, "&Config") menuBar.Append(helpmenu, "&Help") self.SetMenuBar(menuBar) self.Bind(wx.EVT_MENU, self.OnExit, id=ID_EXIT) tb = self.CreateToolBar( wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT | wx.TB_TEXT) #tb.AddSimpleTool(10, wx.Bitmap('images/previous.png'), 'Previous') #tb.AddSimpleTool(20, wx.Bitmap('images/up.png'), 'Up one directory') #tb.AddSimpleTool(30, wx.Bitmap('images/home.png'), 'Home') #tb.AddSimpleTool(40, wx.Bitmap('images/refresh.png'), 'Refresh') #tb.AddSeparator() #tb.AddSimpleTool(50, wx.Bitmap('images/write.png'), 'Editor') #tb.AddSimpleTool(60, wx.Bitmap('images/terminal.png'), 'Terminal') #tb.AddSeparator() #tb.AddSimpleTool(70, wx.Bitmap('images/help.png'), 'Help') tb.AddSimpleTool(10, wx.Bitmap('images/Class.png'), 'Previous') tb.AddSimpleTool(20, wx.Bitmap('images/Class.png'), 'Up one directory') tb.AddSimpleTool(30, wx.Bitmap('images/Class.png'), 'Home') tb.AddSimpleTool(40, wx.Bitmap('images/Class.png'), 'Refresh') tb.AddSeparator() tb.AddSimpleTool(50, wx.Bitmap('images/Class.png'), 'Editor') tb.AddSimpleTool(60, wx.Bitmap('images/Class.png'), 'Terminal') tb.AddSeparator() tb.AddSimpleTool(70, wx.Bitmap('images/Class.png'), 'Help') tb.Realize() self.sizer2 = wx.BoxSizer(wx.HORIZONTAL) button1 = wx.Button(self, ID_BUTTON + 1, "F3 View") button2 = wx.Button(self, ID_BUTTON + 2, "F4 Edit") button3 = wx.Button(self, ID_BUTTON + 3, "F5 Copy") button4 = wx.Button(self, ID_BUTTON + 4, "F6 Move") button5 = wx.Button(self, ID_BUTTON + 5, "F7 Mkdir") button6 = wx.Button(self, ID_BUTTON + 6, "F8 Delete") button7 = wx.Button(self, ID_BUTTON + 7, "F9 Rename") button8 = wx.Button(self, ID_EXIT, "F10 Quit") self.sizer2.Add(button1, 1, wx.EXPAND) self.sizer2.Add(button2, 1, wx.EXPAND) self.sizer2.Add(button3, 1, wx.EXPAND) self.sizer2.Add(button4, 1, wx.EXPAND) self.sizer2.Add(button5, 1, wx.EXPAND) self.sizer2.Add(button6, 1, wx.EXPAND) self.sizer2.Add(button7, 1, wx.EXPAND) self.sizer2.Add(button8, 1, wx.EXPAND) self.Bind(wx.EVT_BUTTON, self.OnExit, id=ID_EXIT) #self.sizer = wx.BoxSizer(wx.VERTICAL) #self.sizer.Add(self.splitter,1,wx.EXPAND) #self.sizer.Add(self.sizer2,0,wx.EXPAND) #self.SetSizer(self.sizer) self.sizer = wx.BoxSizer() self.sizer.Add(p1, 1, wx.EXPAND) self.SetSizer(self.sizer) size = wx.DisplaySize() size = ( size[0]-100, size[1]-100) self.SetSize(size) #self.sb = self.CreateStatusBar() self.sb.SetStatusText(os.getcwd()) self.Center() self.Show(True)
class GameManager(object): def __init__(self, gametype, pgui): self.gui = pgui self.filesystem = FileSystem() self.iohandler = IOHandler(gametype, pgui) self.mapmanager = MapManager(self.filesystem.getData('map')) self.mapmanager.getVisibleObjects() self.messagehandler = MessageHandler( self.filesystem.getData("messages")) self.gamerun = False self.securitycamera = True self.talked = False def start(self): msghandler = self.messagehandler iohandler = self.iohandler if self.gui is None: # Tutorial p = self.mapmanager.getPlayer() iohandler.setOutput(msghandler.getMessage("introduction-welcome")) name = iohandler.getInput( msghandler.getMessage("introduction-name")) p.setName(name) iohandler.setOutput( msghandler.getMessage("introduction-personalwelcome").replace( "%name%", p.getName())) iohandler.setOutput(msghandler.getMessage("introduction-help")) res = iohandler.getInput( msghandler.getMessage("introduction-helpcommands")) while res != "help commands": res = iohandler.getInput( msghandler.getMessage( "general-invalidintroductionhelpcommand")) iohandler.setOutput(msghandler.getMessage("general-seperator")) iohandler.setOutput( msghandler.getMessage("commands-commands-info")) iohandler.setOutput(msghandler.getMessage("introduction-end")) # Game begin self.gamerun = True while self.gamerun: iohandler.setOutput(msghandler.getMessage("general-seperator")) input = self.iohandler.getInput( msghandler.getMessage("general-input")) self.__handleCommand(input) else: msg = msghandler.getMessage("introduction-welcome") msg = msg + "\n" + msghandler.getMessage("introduction-help") msg = msg + "\n" + msghandler.getMessage( "introduction-helpcommands") self.gui.write(msg) self.gui.start() def inputtrigger(self): input = self.iohandler.getInput( self.messagehandler.getMessage("general-input")) self.__handleCommand(input) # TODO: REMOVE L2-KARTE FROM DEFAULT INVENTORY def __handleCommand(self, input: str): msghandler = self.messagehandler iohandler = self.iohandler rawcommand = input.split(" ") command = rawcommand[0] args = rawcommand[1:] if command == "help" and len(args) == 1: iohandler.setOutput( msghandler.getMessage("commands-" + args[0] + "-info")) elif command == "quit": exit(0) elif command == "commands": iohandler.setOutput( msghandler.getMessage("commands-commands-info")) elif command == "left": self.mapmanager.rotatePlayer("left") direction = msghandler.getMessage("turn-left") facing = msghandler.getMessage( "turn-" + self.mapmanager.getPlayer().getFacing()) msg = msghandler.getMessage("turn-general").replace( "%direction%", direction).replace("%facing%", facing) iohandler.setOutput(msg) elif command == "right": self.mapmanager.rotatePlayer("right") direction = msghandler.getMessage("turn-right") facing = msghandler.getMessage( "turn-" + self.mapmanager.getPlayer().getFacing()) msg = msghandler.getMessage("turn-general").replace( "%direction%", direction).replace("%facing%", facing) iohandler.setOutput(msg) elif command == "lookaround": objects = self.mapmanager.getVisibleObjects() for o in objects: direction = o[2] objtype = o[0] msg = "" # left if direction == 0: if objtype == "wall": msg = msghandler.getMessage("lookaround-left").replace( "%object%", msghandler.getMessage("lookaround-wall")) elif objtype == "door": msg = msghandler.getMessage("lookaround-left").replace( "%object%", msghandler.getMessage("lookaround-door")) msg = msg + "\n" + msghandler.getMessage( "lookaround-doorname").replace( "%doorname%", o[1].getName()) msg = msg + "\n" + msghandler.getMessage( "lookaround-doorstatus").replace( "%status%", msghandler.getMessage("lookaround-" + o[1].getStatus())) elif objtype == "object": msg = msghandler.getMessage("lookaround-left").replace( "%object%", o[1].getName()) elif objtype == "narrator": msg = msghandler.getMessage("lookaround-left").replace( "%object%", o[1].getName()) # front elif direction == 1: if objtype == "wall": msg = msghandler.getMessage( "lookaround-front").replace( "%object%", msghandler.getMessage("lookaround-wall")) elif objtype == "door": msg = msghandler.getMessage( "lookaround-front").replace( "%object%", msghandler.getMessage("lookaround-door")) msg = msg + "\n" + msghandler.getMessage( "lookaround-doorname").replace( "%doorname%", o[1].getName()) msg = msg + "\n" + msghandler.getMessage( "lookaround-doorstatus").replace( "%status%", msghandler.getMessage("lookaround-" + o[1].getStatus())) elif objtype == "object": msg = msghandler.getMessage( "lookaround-front").replace( "%object%", o[1].getName()) elif objtype == "narrator": msg = msghandler.getMessage( "lookaround-front").replace( "%object%", o[1].getName()) # right elif direction == 2: if objtype == "wall": msg = msghandler.getMessage( "lookaround-right").replace( "%object%", msghandler.getMessage("lookaround-wall")) elif objtype == "door": msg = msghandler.getMessage( "lookaround-right").replace( "%object%", msghandler.getMessage("lookaround-door")) msg = msg + "\n" + msghandler.getMessage( "lookaround-doorname").replace( "%doorname%", o[1].getName()) msg = msg + "\n" + msghandler.getMessage( "lookaround-doorstatus").replace( "%status%", msghandler.getMessage("lookaround-" + o[1].getStatus())) elif objtype == "object": msg = msghandler.getMessage( "lookaround-right").replace( "%object%", o[1].getName()) elif objtype == "narrator": msg = msghandler.getMessage( "lookaround-right").replace( "%object%", o[1].getName()) if len(msg) > 0: iohandler.setOutput(msg) else: iohandler.setOutput( msghandler.getMessage("lookaround-nothing")) elif command == "move": objects = self.mapmanager.getVisibleObjects() obj = None msg = "" for o in objects: direction = o[2] objtype = o[0] if direction == 1: if objtype == "door": if o[1].getStatus() is not "open": msg = msghandler.getMessage( "lookaround-nomove") + " " obj = o break else: if o[1].getName() == "Portal": self.gamerun = False iohandler.setOutput( msghandler.getMessage("general-portalend")) return else: msg = msghandler.getMessage( "lookaround-nomove") + " " obj = o break if obj is not None: objtype = obj[0] if objtype == "wall": msg = msg + msghandler.getMessage( "lookaround-front").replace( "%object%", msghandler.getMessage("lookaround-wall")) elif objtype == "door": if obj[1].getStatus() is not "open": msg = msg + msghandler.getMessage( "lookaround-front").replace( "%object%", msghandler.getMessage("lookaround-door")) elif objtype == "object": msg = msg + msghandler.getMessage( "lookaround-front").replace("%object%", obj[1].getName()) elif objtype == "narrator": msg = msg + msghandler.getMessage( "lookaround-front").replace("%object%", obj[1].getName()) if len(msg) > 0: iohandler.setOutput(msg) else: p = self.mapmanager.getPlayer() pos = p.getPosition() facing = p.getFacing() if facing == "n": pos = [pos[0], pos[1] + 1] elif facing == "e": pos = [pos[0] + 1, pos[1]] elif facing == "s": pos = [pos[0], pos[1] - 1] elif facing == "w": pos = [pos[0] - 1, pos[1]] p.setPosition(pos) if pos == [6, 15] or pos == [7, 15]: if self.securitycamera: self.gamerun = False iohandler.setOutput( msghandler.getMessage("general-gamefailded")) return iohandler.setOutput(msghandler.getMessage("lookaround-move")) elif command == "goto" and len(args) >= 2: pos = [int(args[0]), int(args[1])] objatpos = self.mapmanager.objectAtPosition(pos) if objatpos is not None: iohandler.setOutput(msghandler.getMessage("goto-nomove")) else: p = self.mapmanager.getPlayer() p.setPosition(pos) iohandler.setOutput( msghandler.getMessage("goto-move").replace( "%x%", args[0]).replace("%y%", args[1])) pass elif command == "showinventory": p = self.mapmanager.getPlayer() inv = p.getInventory() if len(inv) == 0: iohandler.setOutput(msghandler.getMessage("inventory-noitems")) else: msg = msghandler.getMessage("inventory-show") for o in inv: msg = msg + "\n" + o.getName() iohandler.setOutput(msg) elif command == "door" and len(args) >= 1: if not (args[0] == "open" or args[0] == "close"): iohandler.setOutput( msghandler.getMessage("general-invalidcommand")) return objects = self.mapmanager.getVisibleObjects() obj = None for o in objects: direction = o[2] objtype = o[0] if direction == 1 and objtype == "door": obj = o[1] break if obj is None: iohandler.setOutput(msghandler.getMessage("door-nodoor")) return status = obj.getStatus() if status == "broken": iohandler.setOutput(msghandler.getMessage("door-broken")) return if args[0] == "open": if status == "open": iohandler.setOutput( msghandler.getMessage("door-alreadystatus").replace( "%status%", msghandler.getMessage("lookaround-open"))) return elif type(obj) == CardDoor: p = self.mapmanager.getPlayer() inv = p.getInventory() # Find the highest keycard in inventory keylevel = "" for o in inv: if "-Karte" in o.getName(): kl = o.getName().replace("-Karte", "") if len(kl) == 2: if len(keylevel) > 0: kllist = kl.split('') keylevellist = keylevel.split('') if kllist[1] > keylevellist[1]: keylevel = kl else: keylevel = kl # Test for exitdoor: if obj.getName() == "Ausgang": found = False for o in inv: if o.getName() == "USB-Stick": found = True if found: res = obj.open(keylevel) if not res: iohandler.setOutput( msghandler.getMessage("door-noperm")) return else: self.gamerun = False iohandler.setOutput( msghandler.getMessage( "general-gamefinished")) return else: iohandler.setOutput( msghandler.getMessage("door-noexit")) return res = obj.open(keylevel) if not res: iohandler.setOutput( msghandler.getMessage("door-noperm")) else: iohandler.setOutput( msghandler.getMessage("door-action").replace( "%action%", msghandler.getMessage("door-opened"))) # Find a matching door code in the inventory elif type(obj) == CodeDoor: p = self.mapmanager.getPlayer() inv = p.getInventory() res = False for o in inv: if "Pincodezettel-" in o.getName(): code = o.getName().replace("Pincodezettel-", "") res = obj.open(code) if res: iohandler.setOutput( msghandler.getMessage("door-action"). replace( "%action%", msghandler.getMessage("door-opened"))) return if not res: iohandler.setOutput( msghandler.getMessage("door-noperm")) else: obj.open() elif args[0] == "close": if status == "close": iohandler.setOutput( msghandler.getMessage("door-alreadystatus").replace( "%status%", msghandler.getMessage("lookaround-close"))) return else: obj.close() iohandler.setOutput( msghandler.getMessage("door-action").replace( "%action%", msghandler.getMessage("door-closed"))) elif command == "getposition": p = self.mapmanager.getPlayer() pos = p.getPosition() iohandler.setOutput( msghandler.getMessage("goto-position").replace( "%x%", str(pos[0])).replace("%y%", str(pos[1]))) elif command == "facing": p = self.mapmanager.getPlayer() facing = p.getFacing() facingmsg = msghandler.getMessage("turn-" + facing) iohandler.setOutput( msghandler.getMessage("turn-facing").replace( "%facing%", facingmsg)) elif command == "object" and len(args) >= 1: if not (args[0] == "showinventory" or args[0] == "getitem" or args[0] == "putitem" or args[0] == "move"): iohandler.setOutput( msghandler.getMessage("general-invalidcommand")) return objects = self.mapmanager.getVisibleObjects() obj = None for o in objects: direction = o[2] objtype = o[0] if direction == 1 and objtype == "object": obj = o[1] break if obj is None: iohandler.setOutput(msghandler.getMessage("object-noobject")) return if args[0] == "showinventory": inv = obj.getInventory() if len(inv) == 0: iohandler.setOutput( msghandler.getMessage("object-noitems").replace( "%objectname%", obj.getName())) return else: msg = msghandler.getMessage("object-show").replace( "%objectname%", obj.getName()) for o in inv: msg = msg + "\n" + o.getName() iohandler.setOutput(msg) elif args[0] == "getitem" and len(args) >= 2: inv = obj.getInventory() p = self.mapmanager.getPlayer() pinv = p.getInventory() for o in inv: if o.getName() == args[1]: inv.remove(o) obj.setInventory(inv) pinv.append(o) p.setInventory(pinv) iohandler.setOutput( msghandler.getMessage("object-get").replace( "%item%", o.getName()).replace("%objectname%", obj.getName())) return iohandler.setOutput( msghandler.getMessage("object-noget").replace( "%name%", args[1]).replace("%objectname%", obj.getName())) elif args[0] == "putitem" and len(args) >= 2: inv = obj.getInventory() p = self.mapmanager.getPlayer() pinv = p.getInventory() for o in pinv: if o.getName() == args[1]: pinv.remove(o) p.setInventory(pinv) inv.append(o) obj.setInventory(inv) iohandler.setOutput( msghandler.getMessage("object-put").replace( "%item%", o.getName()).replace("%objectname%", obj.getName())) return iohandler.setOutput( msghandler.getMessage("object-noput").replace( "%name%", args[1])) elif args[0] == "move" and len(args) >= 2: if not (args[1] == "left" or args[1] == "right" or args[1] == "forward"): iohandler.setOutput( msghandler.getMessage("general-invalidcommand")) return p = self.mapmanager.getPlayer() ppos = p.getPosition() pfacing = p.getFacing() if not obj.isMovable(): iohandler.setOutput( msghandler.getMessage("object-nomove").replace( "%objectname%", obj.getName())) return objpos = obj.getPosition() postomove = objpos if pfacing == "n": if args[1] == "left": postomove = [objpos[0] - 1, objpos[1]] elif args[1] == "right": postomove = [objpos[0] + 1, objpos[1]] elif args[1] == "forward": postomove = [objpos[0], objpos[1] + 1] elif pfacing == "e": if args[1] == "left": postomove = [objpos[0], objpos[1] + 1] elif args[1] == "right": postomove = [objpos[0], objpos[1] - 1] elif args[1] == "forward": postomove = [objpos[0] + 1, objpos[1]] elif pfacing == "s": if args[1] == "left": postomove = [objpos[0] + 1, objpos[1]] elif args[1] == "right": postomove = [objpos[0] - 1, objpos[1]] elif args[1] == "forward": postomove = [objpos[0], objpos[1] - 1] elif pfacing == "w": if args[1] == "left": postomove = [objpos[0], objpos[1] - 1] elif args[1] == "right": postomove = [objpos[0], objpos[1] + 1] elif args[1] == "forward": postomove = [objpos[0] - 1, objpos[1]] objatpos = self.mapmanager.objectAtPosition(postomove) if objatpos is not None: objname = "" if type(objatpos) == list: objname = msghandler.getMessage("lookaround-wall") elif type(objatpos) == Object: objname = objatpos.getName() else: objname = msghandler.getMessage("lookaround-door") iohandler.setOutput( msghandler.getMessage("object-nomoveblocked").replace( "%objectname%", objname)) return obj.setPosition(postomove) dir = msghandler.getMessage("turn-" + args[1]) iohandler.setOutput( msghandler.getMessage("object-moved").replace( "%direction%", dir)) elif command == "hackserver": objects = self.mapmanager.getVisibleObjects() obj = None msg = "" for o in objects: direction = o[2] objtype = o[0] if direction == 1: if type(o[1]) == Object: if o[1].getName() == "Server": obj = o[1] break if not obj: msg = msghandler.getMessage("server-noserver") else: if not self.securitycamera: msg = msghandler.getMessage("server-alreadyhacked") else: self.securitycamera = False msg = msghandler.getMessage("server-hacked") iohandler.setOutput(msg) elif command == "talk": objects = self.mapmanager.getVisibleObjects() obj = None msg = "" for o in objects: direction = o[2] objtype = o[0] if direction == 1: if objtype == "narrator": obj = o[1] if obj is None: msg = msghandler.getMessage("talk-notalk") else: if self.talked: msg = msghandler.getMessage("talk-talk") else: msg = msghandler.getMessage("talk-talk") self.talked = True p = self.mapmanager.getPlayer() inv = p.getInventory() key = Object("L2-Karte", 999, False, True, None, None) inv.append(key) p.setInventory(inv) msg = msg + "\n" + msghandler.getMessage("talk-keycard") iohandler.setOutput(msg) else: iohandler.setOutput( msghandler.getMessage("general-invalidcommand"))
rImportantStdOutLines = rImportantStdOutLines, rImportantStdErrLines = rImportantStdErrLines, bGetDetailsHTML = dxConfig["bSaveReport"], fApplicationRunningCallback = fApplicationRunningHandler, fExceptionDetectedCallback = fExceptionDetectedHandler, fApplicationExitCallback = fApplicationExitHandler, ); oBugId.fWait(); if oBugId.oBugReport: print "* A bug was detected in the application."; print; print " Id: %s" % oBugId.oBugReport.sId; print " Description: %s" % oBugId.oBugReport.sBugDescription; print " Location: %s" % oBugId.oBugReport.sBugLocation; if oBugId.oBugReport.sBugSourceLocation: print " Source: %s" % oBugId.oBugReport.sBugSourceLocation; print " Security impact: %s" % oBugId.oBugReport.sSecurityImpact; if dxConfig["bSaveReport"]: sReportFileName = "%s @ %s.html" % (oBugId.oBugReport.sId, oBugId.oBugReport.sBugLocation); eWriteDataToFileResult = FileSystem.feWriteDataToFile( oBugId.oBugReport.sDetailsHTML, FileSystem.fsLocalPath(FileSystem.fsTranslateToValidName(sReportFileName)), fbRetryOnFailure = lambda: False, ); if eWriteDataToFileResult: print " Bug report: Cannot be saved (%s)" % repr(eWriteDataToFileResult); else: print " Bug report: %s (%d bytes)" % (sReportFileName, len(oBugId.oBugReport.sDetailsHTML)); else: print "* The application has terminated without crashing.";
import FileSystem FileSystem.Initialize_My_FileSystem() interface = FileSystem.FileSystemOperations() #1. MAKING NEW DIRECTORY ''' interface.mkdir("/A") interface.mkdir("/A/B") interface.mkdir("/A/B/C") interface.mkdir("D") interface.status() ''' #2. WRITING NEW FILES AND READING. [[BEFORE WRTING WE HAVE TO CRTEATE THE FILE ]] ''' interface.create("/1.txt") interface.write("/1.txt", "Principles of Computer System Design") interface.mkdir("/A") interface.create("/A/2.txt") interface.write("/A/2.txt", "Hello World!") interface.status() interface.read("/1.txt") interface.read("/A/2.txt", 2, 3) #reading only 3 words from offset 2 (including the offset) ''' #3. OVERWIRING OR APPEND FILE AT THE GIVEN OFFSET. ''' interface.create("/1.txt") interface.write("/1.txt", "ABC") interface.read("/1.txt")
from cBugId import cBugId; from cBugId.sOSISA import sOSISA; from cBugId.cBugReport_foAnalyzeException_STATUS_ACCESS_VIOLATION import ddtsDetails_uAddress_sISA; import FileSystem; asTestISAs = [sOSISA]; if sOSISA == "x64": asTestISAs.append("x86"); sBaseFolderPath = os.path.dirname(__file__); dsBinaries_by_sISA = { "x86": os.path.join(sBaseFolderPath, r"Tests\bin\Tests_x86.exe"), "x64": os.path.join(sBaseFolderPath, r"Tests\bin\Tests_x64.exe"), }; sReportsFolderName = FileSystem.fsLocalPath("Sample reports"); bFailed = False; oOutputLock = threading.Lock(); # If you see weird exceptions, try lowering the number of parallel tests: oConcurrentTestsSemaphore = threading.Semaphore(uSequentialTests); class cTest(object): def __init__(oTest, sISA, asCommandLineArguments, sExpectedBugTypeId): oTest.sISA = sISA; oTest.asCommandLineArguments = asCommandLineArguments; oTest.sExpectedBugTypeId = sExpectedBugTypeId; oTest.bInternalException = False; oTest.bHasOutputLock = False; def __str__(oTest): return "%s =%s=> %s" % (" ".join(oTest.asCommandLineArguments), oTest.sISA, oTest.sExpectedBugTypeId);
import FileSystem as fs import Functions as fn import Image as img import Print as prn if (len(sys.argv) > 1): in_path = str(sys.argv[1]).strip().replace('"', '') if os.path.isdir(in_path): conf.paths = [in_path] prn.print_(in_path, "path") for dir in conf.paths: files = list(fs.GetAllFiles(dir)) for file in files: file_info = FileInfo(file, dir) if file_info.extension in conf.video_ext: if not fn.CorrespondingContactSheetExists( os.path.join(file_info.folder, fs.FileNameOnly(file_info.filename)), conf.contact_ext, files): try: img.create_contact_sheet(file_info.fullfilename) except:
name = '/d' * (i) + '/f' my_object.rm(name) if __name__ == '__main__': if len(sys.argv) != 2 and len(sys.argv) != 3: print("Must (only) specify raid mode.") quit() raid_mode = sys.argv[1] if raid_mode != '1' and raid_mode != '5': print("Must use raid mode 1 or 5 - terminating program.") quit() FileSystem.Initialize_My_FileSystem(4, raid_mode) if (len(sys.argv) < 3): my_object = FileSystemOperations() print('Delaying 5s to allow termination of a server.') print('Server may also be terminated during execution.') time.sleep(5) for i in range(12): name = '/d' * (i + 1) my_object.mkdir(name) test_case_6(my_object) test_case_7(my_object) test_case_8(my_object) my_object.create('/f') my_object.mv('/f', '/d/f') my_object.rm('/d/f') print('\nTests Complete.')
def fFinishedHandler(oTest, oBugReport): global bFailed, oOutputLock; try: if not bFailed: oOutputLock and oOutputLock.acquire(); oTest.bHasOutputLock = True; if oTest.sExpectedBugTypeId: if not oBugReport: print "- Failed test: %s" % " ".join([dsBinaries_by_sISA[oTest.sISA]] + oTest.asCommandLineArguments); print " Expected: %s" % oTest.sExpectedBugTypeId; print " Got nothing"; bFailed = True; elif not oTest.sExpectedBugTypeId == oBugReport.sBugTypeId: print "- Failed test: %s" % " ".join([dsBinaries_by_sISA[oTest.sISA]] + oTest.asCommandLineArguments); print " Expected: %s" % oTest.sExpectedBugTypeId; print " Reported: %s @ %s" % (oBugReport.sId, oBugReport.sBugLocation); print " %s" % (oBugReport.sBugDescription); bFailed = True; else: print "+ %s" % oTest; elif oBugReport: print "- Failed test: %s" % " ".join([dsBinaries_by_sISA[oTest.sISA]] + oTest.asCommandLineArguments); print " Expected no report"; print " Reported: %s @ %s" % (oBugReport.sId, oBugReport.sBugLocation); print " %s" % (oBugReport.sBugDescription); bFailed = True; else: print "+ %s" % oTest; oOutputLock and oOutputLock.release(); oTest.bHasOutputLock = False; if bSaveTestReports and oBugReport: # We'd like a report file name base on the BugId, but the later may contain characters that are not valid in a file name sDesiredReportFileName = "%s @ %s.html" % (oBugReport.sId, oBugReport.sBugLocation); # Thus, we need to translate these characters to create a valid filename that looks very similar to the BugId sValidReportFileName = FileSystem.fsTranslateToValidName(sDesiredReportFileName, bUnicode = dxConfig["bUseUnicodeReportFilenames"]); ebCreateFolderResult = FileSystem.febCreateFolder( sReportsFolderName, oTest.asCommandLineArguments[0], # Type of crash fbRetryOnFailure = lambda: False, ); if not isinstance(ebCreateFolderResult, bool): oOutputLock and oOutputLock.acquire(); oTest.bHasOutputLock = True; print "- Failed test: %s" % " ".join([dsBinaries_by_sISA[oTest.sISA]] + oTest.asCommandLineArguments); print " Bug report cannot be saved becasue the folder %s\%s cannot be created (%s)" % \ (sReportsFolderName, oTest.asCommandLineArguments[0], repr(eCreateFolderResult)); oOutputLock and oOutputLock.release(); oTest.bHasOutputLock = False; bFailed = True; return; eWriteDataToFileResult = FileSystem.feWriteDataToFile( oBugReport.sDetailsHTML, sReportsFolderName, oTest.asCommandLineArguments[0], # Type of crash sValidReportFileName, fbRetryOnFailure = lambda: False, ); if eWriteDataToFileResult: oOutputLock and oOutputLock.acquire(); oTest.bHasOutputLock = True; print "- Failed test: %s" % " ".join([dsBinaries_by_sISA[oTest.sISA]] + oTest.asCommandLineArguments); print " Bug report cannot be saved (%s)" % repr(eWriteDataToFileResult); oOutputLock and oOutputLock.release(); oTest.bHasOutputLock = False; bFailed = True; return; finally: oTest.fFinished(); oTest.bHandlingResult = False;
import FileSystem from Process import * # TODO:优化中断表现形式 from kernal import IOSystem, Memory import IOSystem, Memory from kernal.ProcessorSchedulingForBackEnd import prioritySchedulingSyncForBackEnd, prioritySchedulingAsyncForBackEnd, \ fcfsForBackEnd, roundRobinForBackEnd from ProcessorSchedulingForBackEnd import prioritySchedulingSyncForBackEnd, prioritySchedulingAsyncForBackEnd, \ fcfsForBackEnd if __name__ == '__main__': # 现在,各个模块必须进行初始化 s, root, Disk, file_table = FileSystem.initFileSystem() d_table = IOSystem.initIO() m = Memory.initMemory() swap_queue = [] # 进程swap空间(队列) process_now_queue = [] # 进程执行队列 process_running = None # 上一个周期执行的进程,无需传给前端 process_cur = None # 正在执行的进程 code = -1 time_slice = 2 print('旧文件内容:' + FileSystem.readFile('test', root)) # process_queue = [Process(DataType.Default, 0, 5, priority=10), Process(DataType.Default, 1, 3, priority=8), # Process(DataType.Default, 3, 6, priority=12), # Process(DataType.IO, 8, 8, IO_operation_time=5, priority=7, target_device=d_table[1], # request_content="这是个IO请求"), # Process(DataType.IO, 11, 3, IO_operation_time=2, priority=4, target_device=d_table[0], # request_content="writeFile|test|新内容!"),
def removeDirectory(strDirToDelete): if os.path.isfile(strDirToDelete): strDirToDelete = os.path.dirname(strDirToDelete) logger.info("Deleting %s" % strDirToDelete) FileSystem.deleteDir(strDirToDelete)
def fuMain(asArguments): # returns an exit code, values are: # 0 = executed successfully, no bugs found. # 1 = executed successfully, bug detected. # 2 = bad arguments # 3 = internal error global oBugId, bApplicationIsStarted, bCheckForExcessiveCPUUsageTimeoutSet; # Parse all "--" arguments until we encounter a non-"--" argument. auApplicationProcessIds = []; sApplicationISA = None; dxUserProvidedConfigSettings = {}; while asArguments and asArguments[0].startswith("--"): sArgument = asArguments.pop(0); sSettingName, sValue = sArgument[2:].split("=", 1); if sSettingName in ["pid", "pids"]: auApplicationProcessIds += [long(x) for x in sValue.split(",")]; elif sSettingName == "isa": if sValue not in ["x86", "x64"]: print "- Unknown ISA %s" % repr(sValue); return 2; sApplicationISA = sValue; else: try: xValue = json.loads(sValue); except ValueError: print "- Cannot decode argument JSON value %s" % sValue; return 2; # User provided config settings must be applied after any keyword specific config settings: dxUserProvidedConfigSettings[sSettingName] = xValue; dsURLTemplate_by_srSourceFilePath = {}; rImportantStdOutLines = None; rImportantStdErrLines = None; # If there are any additional arguments, it must be an application keyword followed by additional arguments # or an application command-line: if not asArguments: # No keyword or command line: process ids to attach to must be provided asApplicationCommandLine = None; if not auApplicationProcessIds: print "You must specify an application command-line, keyword or process ids"; return 2; else: # First argument may be an application keyword sApplicationKeyword = None; sApplicationBinary = None; if "=" in asArguments[0]: # user provided an application keyword and binary sApplicationKeyword, sApplicationBinary = asArguments.pop(0).split("=", 1); elif asArguments[0] in asApplicationKeywords or asArguments[0][-1] == "?": # user provided an application keyword, or requested information on something that may be one: sApplicationKeyword = asArguments.pop(0); asApplicationCommandLine = None; if sApplicationKeyword: if sApplicationKeyword[-1] == "?": # User requested information about a possible keyword application return fuShowApplicationKeyWordHelp(sApplicationKeyword[:-1]); # Get application command line for keyword, if available: if sApplicationKeyword in gdApplication_asCommandLine_by_sKeyword: if auApplicationProcessIds: print "You cannot specify process ids for application %s" % sApplicationKeyword; return 2; asApplicationCommandLine = gdApplication_asCommandLine_by_sKeyword[sApplicationKeyword]; if sApplicationBinary: # Replace binary with user provided value asApplicationCommandLine = [sApplicationBinary] + asApplicationCommandLine[1:]; else: if asApplicationCommandLine[0] is None: print "Application %s does not appear to be installed"; return 2; if asArguments: # Add user provided additional application arguments: asApplicationCommandLine += asArguments; elif sApplicationKeyword in gdApplication_asDefaultAdditionalArguments_by_sKeyword: # Add default additional application arguments: asApplicationCommandLine += [ sArgument is DEFAULT_BROWSER_TEST_URL and dxConfig["sDefaultBrowserTestURL"] or sArgument for sArgument in gdApplication_asDefaultAdditionalArguments_by_sKeyword[sApplicationKeyword] ]; elif asArguments: print "You cannot specify arguments for application keyword %s" % sApplicationKeyword; return 2; elif not auApplicationProcessIds: print "You must specify process ids for application keyword %s" % sApplicationKeyword; return 2; # Apply application specific settings if sApplicationKeyword in gdApplication_dxSettings_by_sKeyword: print "* Applying application specific settings:"; for (sSettingName, xValue) in gdApplication_dxSettings_by_sKeyword[sApplicationKeyword].items(): if sSettingName not in dxUserProvidedConfigSettings: fApplyConfigSetting(sSettingName, xValue, " "); # Apply and show result indented. # Apply application specific source settings if sApplicationKeyword in gdApplication_sURLTemplate_by_srSourceFilePath_by_sKeyword: dsURLTemplate_by_srSourceFilePath = gdApplication_sURLTemplate_by_srSourceFilePath_by_sKeyword[sApplicationKeyword]; # Apply application specific stdio settings: if sApplicationKeyword in gdApplication_rImportantStdOutLines_by_sKeyword: rImportantStdOutLines = gdApplication_rImportantStdOutLines_by_sKeyword[sApplicationKeyword]; if sApplicationKeyword in gdApplication_rImportantStdErrLines_by_sKeyword: rImportantStdErrLines = gdApplication_rImportantStdErrLines_by_sKeyword[sApplicationKeyword]; if not sApplicationISA and sApplicationKeyword in gdApplication_sISA_by_sKeyword: # Apply application specific ISA sApplicationISA = gdApplication_sISA_by_sKeyword[sApplicationKeyword]; elif auApplicationProcessIds: # user provided an application command-line and process ids print "You cannot specify both an application command-line and process ids"; return 2; else: # user provided an application command-line asApplicationCommandLine = asArguments; # Apply user provided settings: for (sSettingName, xValue) in dxUserProvidedConfigSettings.items(): fApplyConfigSetting(sSettingName, xValue); # Apply and show result bApplicationIsStarted = asApplicationCommandLine is None; # if we're attaching the application is already started. if asApplicationCommandLine: print "+ The debugger is starting the application..."; print " Command line: %s" % " ".join(asApplicationCommandLine); else: print "+ The debugger is attaching to the application..."; oBugId = cBugId( sCdbISA = sApplicationISA or sOSISA, asApplicationCommandLine = asApplicationCommandLine or None, auApplicationProcessIds = auApplicationProcessIds or None, asSymbolServerURLs = dxConfig["asSymbolServerURLs"], dsURLTemplate_by_srSourceFilePath = dsURLTemplate_by_srSourceFilePath, rImportantStdOutLines = rImportantStdOutLines, rImportantStdErrLines = rImportantStdErrLines, bGetDetailsHTML = dxConfig["bSaveReport"], fApplicationRunningCallback = fApplicationRunningHandler, fExceptionDetectedCallback = fExceptionDetectedHandler, fApplicationExitCallback = fApplicationExitHandler, fInternalExceptionCallback = fInternalExceptionCallback, ); oBugId.fWait(); if not bApplicationIsStarted: print "- BugId was unable to debug the application."; return 3; elif oInternalException is not None: print "+ BugId run into an internal error:"; print " %s" % repr(oInternalException); print; print " Please report this issue at the below web-page so it can be addressed:"; print " https://github.com/SkyLined/BugId/issues/new"; return 3; elif oBugId.oBugReport is not None: print "+ A bug was detected in the application."; print; print " === BugId report (https://github.com/SkyLined/BugId) ".ljust(80, "="); print " Id: %s" % oBugId.oBugReport.sId; print " Location: %s" % oBugId.oBugReport.sBugLocation; print " Description: %s" % oBugId.oBugReport.sBugDescription; print " Version: %s" % oBugId.oBugReport.asVersionInformation[0]; # There is always the process' binary. for sVersionInformation in oBugId.oBugReport.asVersionInformation[1:]: # There may be two if the crash was in a print " %s" % sVersionInformation; # different binary (e.g. a .dll) if oBugId.oBugReport.sBugSourceLocation: print " Source: %s" % oBugId.oBugReport.sBugSourceLocation; print " Security impact: %s" % oBugId.oBugReport.sSecurityImpact; print " Run time: %s seconds" % (long(oBugId.fnApplicationRunTime() * 1000) / 1000.0); if dxConfig["bSaveReport"]: # We'd like a report file name base on the BugId, but the later may contain characters that are not valid in a file name sDesiredReportFileName = "%s @ %s.html" % (oBugId.oBugReport.sId, oBugId.oBugReport.sBugLocation); # Thus, we need to translate these characters to create a valid filename that looks very similar to the BugId sValidReportFileName = FileSystem.fsValidName(sDesiredReportFileName, bUnicode = dxConfig["bUseUnicodeReportFileNames"]); if dxConfig["sReportFolderPath"] is not None: sReportFilePath = FileSystem.fsPath(dxConfig["sReportFolderPath"], sValidReportFileName); else: sReportFilePath = FileSystem.fsPath(sValidReportFileName); eWriteDataToFileResult = FileSystem.feWriteDataToFile( oBugId.oBugReport.sDetailsHTML, sReportFilePath, fbRetryOnFailure = lambda: False, ); if eWriteDataToFileResult: print " Bug report: Cannot be saved (%s)" % repr(eWriteDataToFileResult); else: print " Bug report: %s (%d bytes)" % (sValidReportFileName, len(oBugId.oBugReport.sDetailsHTML)); return 1; else: print "- The application has terminated without crashing."; print " Run time: %s seconds" % (long(oBugId.fnApplicationRunTime() * 1000) / 1000.0); return 0;
def setupWorkspace(self): print("Setting up workspaces for project [%s]" % self._project_name) self.cleanBuildWorkspace() Utilities.mkdir(FileSystem.getDirectory(FileSystem.WORKING, self._config, self._project_name)) self.buildAndLoadDependencies()
parser = argparse.ArgumentParser(description='Peer-to-Peer system Evaluation Program') parser.add_argument('-M', '--filesize',type=str, default = '3', help = 'number of files initialized in a client') parser.add_argument('-N', '--requestsize',type=str, default = '1', help = 'number of readfile one client triggered') parser.add_argument('-F', '--frequency',type=str, default = '1', help = 'frequency of tasks triggered') args = parser.parse_args() M = int(args.filesize) N = int(args.requestsize) F = float(args.frequency) response_record = defaultdict(list) response_record = defaultdict(list) response_record["data/client_1/"] = [0,0] fs.reset_stats() client_threads = run_client(response_record, "data/client_1/", F, M, N) for t in client_threads: t.join() print('='*21 + 'statistics' + '='*21) fn='stats_response_time.csv' accu,count = response_record["data/client_1/"] print("Average respond time in {0} is {1:4f}".format("data/client_1/",accu/count))
def run_ds(ds): ds.launch_bp_directory_server_thread() ds.run() if __name__ == "__main__": parser = argparse.ArgumentParser(description='File system Evaluation Program') parser.add_argument('-T', '--down_time',type=str, default = '10', help = 'time from start the directory node was killed') args = parser.parse_args() T = int(args.down_time) fs.reset_stats() storage_nodes = [((fs.StorageServerIP, fs.StorageServerPortBase + 1), 1), ((fs.StorageServerIP, fs.StorageServerPortBase + 2), 1), ((fs.StorageServerIP, fs.StorageServerPortBase + 3), 1)] ds = fs.DirectoryServer(fs.DirectoryServerIP, fs.DirectoryServerPortBase + 1, storage_nodes) ds.primary = True i_thread = threading.Thread(target=run_ds, args=(ds,)) i_thread.daemon = True i_thread.start() try: time.sleep(T) ds.stop() time.sleep(3000)
def cleanBuildWorkspace(self): print("Cleaning build directory for project [%s]" % self._project_name) buildDirectory = FileSystem.getDirectory(FileSystem.WORKING, self._config, self._project_name) if os.path.exists(buildDirectory): Utilities.rmTree(buildDirectory)
ext = fs.getExtension(filePath) size = fs.getFileSize(filePath) fileName = fs.getFileName(filePath) filePath = filePath.replace("\\", "/") filePath = filePath.replace("'", "''") hexa = bin2hex(filePath) sql = Text.format(INSERT, fileName, filePath, ext, hexa, size) client = mysql.MySQL() client.execute(sql) return # バイナリーファイルをヘキサに変換する。 def bin2hex(filePath): buff = "0x" b = fs.readBinary(filePath) buff += b.hex() return buff # メイン if Common.count_args() == 0: Common.stop("ファイルを指定してください。") filePath = Common.args()[0] if fs.exists(filePath): insertBinaries(filePath) print('Done. ' + filePath) else: Common.esc_print("red", filePath + ' does NOT exists.')
def repl(): fs = None fsExists = False prompt = '> ' cmd = '' sys.stdout.write(prompt) sys.stdout.flush() for line in sys.stdin: words = line.split() if len(words) == 0: pass elif words[0] in ('exit', 'quit'): print("Bye!") quit() elif words[0] == 'newfs': if len(words) < 3 and len(words) > 4: print('Number of arguments to the command incorrect. please use the following: newfs <filename> <block_count> [optional block size]') elif len(words) == 3: if tryAsNum(words[2]): FileSystem.createFileSystem(words[1], int(words[2])) elif len(words) == 4: if tryAsNum(words[2]) and tryAsNum(words[3]): FileSystem.createFileSystem(words[1], int(words[2]), int(words[3])) else: print('There were too many arguments. Please try again') elif words[0] == 'mount': if len(words) != 2: print('Number of arguments to the command incorrect. please use the following: mount <filename>') elif fsExists == True: print("file system already mounted. Cannot mount another one") else: fs = FileSystem(words[1]) try: fs except NameError: fsExists = False else: fsExists = True ######## EVERYTHING PAST THIS LINE MUST CHECK FOR FS #### elif words[0] == 'blockmap' and fsExists: if len(words) != 1: print('Number of arguments to the command incorrect. please use the following: blockmap') else: fs.getBlockMap() elif words[0] == 'alloc_block' and fsExists: if len(words) != 1: print('Number of arguments to the command incorrect. please use the following: alloc_block') else: fs.alloc_Block() elif words[0] == 'free_block' and fsExists: if len(words) != 2: print('Number of arguments to the command incorrect. please use the following: free_block <n>') else: if tryAsNum(words[1]): fs.free_Block(int(words[1])) elif words[0] == 'inode_map' and fsExists: if len(words) != 1: print('Number of arguments to the command incorrect. please use the following: inode_map') else: fs.getInodeMap() elif words[0] == 'alloc_inode' and fsExists: if len(words) != 2: print('Number of arguments to the command incorrect. please use the following: alloc_inode <type>\n Types are: 0 = free, f = file, d = Dir, s = symLink, b = block pointer, D = Data') else: fs.alloc_INode(words[1]) elif words[0] == 'free_inode' and fsExists: if len(words) != 2: print('Number of arguments to the command incorrect. please use the following: free_inode <number>') else: if tryAsNum(words[1]): fs.free_INode(int(words[1])) elif words[0] == 'unmount' and fsExists: if len(words) != 1: print('Number of arguments to the command incorrect. please use the following: unmount') else: fs.unmount fsExists = False del fs else: print("unknown command {}".format(words[0])) sys.stdout.write(prompt) sys.stdout.flush() # all done, clean exit print("Bye!")
def bin2hex(filePath): buff = "0x" b = fs.readBinary(filePath) buff += b.hex() return buff
def fuMain(asArguments): global gbQuiet, \ gasAttachToProcessesForBinaryNames if len(asArguments) == 0: fPrintLogo() fPrintUsage(asApplicationKeywords) return 0 # returns an exit code, values are: # 0 = executed successfully, no bugs found. # 1 = executed successfully, bug detected. # 2 = bad arguments # 3 = internal error # 4 = failed to start process or attach to process(es). # Parse all "--" arguments until we encounter a non-"--" argument. sApplicationKeyword = None sApplicationBinaryPath = None auApplicationProcessIds = [] sApplicationPackageName = None sApplicationId = None asApplicationOptionalArguments = None sApplicationISA = None bRepeat = False bCheckForUpdates = False dxUserProvidedConfigSettings = {} bFast = False while asArguments: sArgument = asArguments.pop(0) if sArgument == "--": if len(auApplicationProcessIds) > 0: # The rest of the arguments are to be passed to the application oConsole.fPrint( ERROR, "- You cannot supply process ids and application arguments." ) return 2 asApplicationOptionalArguments = asArguments break elif sArgument in ["-q", "/q"]: gbQuiet = True elif sArgument in ["-f", "/f"]: bFast = True elif sArgument in ["-r", "/r"]: bRepeat = True elif sArgument in ["-?", "/?", "-h", "/h"]: fPrintLogo() fPrintUsage(asApplicationKeywords) return 0 elif sArgument.startswith("--"): if "=" in sArgument: sSettingName, sValue = sArgument[2:].split("=", 1) else: # "--bFlag" is an alias for "--bFlag=true" sSettingName = sArgument[2:] sValue = "true" if sSettingName in ["pid", "pids"]: if sApplicationBinaryPath is not None: oConsole.fPrint( ERROR, "- You cannot supply an application binary and process ids." ) return 2 if sApplicationPackageName is not None: oConsole.fPrint( ERROR, "- You cannot supply an application package name and process ids." ) return 2 auApplicationProcessIds += [ long(x) for x in sValue.split(",") ] elif sSettingName in ["uwp", "uwp-app"]: if sApplicationPackageName is not None: oConsole.fPrint( ERROR, "- You cannot supply two or more application package names." ) return 2 if sApplicationBinaryPath is not None: oConsole.fPrint( ERROR, "- You cannot supply an application binary and package name." ) return 2 if len(auApplicationProcessIds) > 0: oConsole.fPrint( ERROR, "- You cannot supply process ids and an application package name." ) return 2 if "!" not in sValue: oConsole.fPrint( ERROR, "- Please provide a string of the form %s=<package name>!<application id>.", sSettingName) return 2 sApplicationPackageName, sApplicationId = sValue.split("!", 1) elif sSettingName in ["version", "check-for-updates"]: return fuVersionCheck() elif sSettingName in ["isa", "cpu"]: if sValue not in ["x86", "x64"]: oConsole.fPrint(ERROR, "- Unknown ISA %s" % repr(sValue)) return 2 sApplicationISA = sValue elif sSettingName in ["quiet", "silent"]: gbQuiet = sValue.lower() == "true" elif sSettingName in ["fast", "quick"]: bFast = True elif sSettingName in ["repeat", "forever"]: bRepeat = True else: try: xValue = json.loads(sValue) except ValueError: oConsole.fPrint( ERROR, "- Cannot decode argument JSON value %s." % sValue) return 2 # User provided config settings must be applied after any keyword specific config settings: dxUserProvidedConfigSettings[sSettingName] = xValue elif sArgument in asApplicationKeywords: if sApplicationKeyword is not None: oConsole.fPrint( ERROR, "- You cannot supply two or more application keywords.") return 2 sApplicationKeyword = sArgument elif sArgument[-1] == "?" and sArgument[:-1] in asApplicationKeywords: return fuShowApplicationKeyWordHelp(sArgument[:-1]) else: if sApplicationBinaryPath is not None: oConsole.fPrint( ERROR, "- You cannot supply two or more application binaries.") return 2 if len(auApplicationProcessIds) > 0: oConsole.fPrint( ERROR, "- You cannot supply process ids and an application binary." ) return 2 if sApplicationPackageName is not None: oConsole.fPrint( ERROR, "- You cannot supply an application package name and a binary." ) return 2 sApplicationBinaryPath = sArgument if bFast: gbQuiet = True dxUserProvidedConfigSettings["bGenerateReportHTML"] = False dxUserProvidedConfigSettings["asSymbolServerURLs"] = [] dxUserProvidedConfigSettings["cBugId.bUse_NT_SYMBOL_PATH"] = False dsURLTemplate_by_srSourceFilePath = {} rImportantStdOutLines = None rImportantStdErrLines = None if sApplicationKeyword: # Get application binary/package name/process ids as needed: if sApplicationKeyword in gdApplication_sBinaryPath_by_sKeyword: # This application is started from the command-line. if auApplicationProcessIds: oConsole.fPrint( ERROR, "- You cannot specify process ids for application keyword ", INFO, sApplicationKeyword, NORMAL, ".") return 2 if sApplicationPackageName: oConsole.fPrint( ERROR, "- You cannot specify an application package name for application keyword ", INFO, sApplicationKeyword, NORMAL, ".") return 2 if sApplicationBinaryPath is None: sApplicationBinaryPath = gdApplication_sBinaryPath_by_sKeyword[ sApplicationKeyword] elif sApplicationKeyword in gsApplicationPackageName_by_sKeyword: # This application is started as an application package. if sApplicationBinaryPath: oConsole.fPrint( ERROR, "- You cannot specify an application binary for application keyword ", INFO, sApplicationKeyword, NORMAL, ".") return 2 sApplicationPackageName = gsApplicationPackageName_by_sKeyword[ sApplicationKeyword] sApplicationId = gsApplicationId_by_sKeyword[sApplicationKeyword] elif not auApplicationProcessIds: # This application is attached to. oConsole.fPrint( ERROR, "- You must specify process ids for application keyword ", INFO, sApplicationKeyword, NORMAL, ".") return 2 elif asApplicationOptionalArguments: # Cannot supply arguments if we're attaching to processes oConsole.fPrint( ERROR, "- You cannot specify arguments for application keyword ", INFO, sApplicationKeyword, NORMAL, ".") return 2 if sApplicationKeyword in gasApplicationAttachToProcessesForBinaryNames_by_sKeyword: gasAttachToProcessesForBinaryNames = gasApplicationAttachToProcessesForBinaryNames_by_sKeyword[ sApplicationKeyword] # Get application arguments; asApplicationStaticArguments = gdApplication_asStaticArguments_by_sKeyword.get( sApplicationKeyword, []) if asApplicationOptionalArguments is None: asApplicationOptionalArguments = [ sArgument is DEFAULT_BROWSER_TEST_URL and dxConfig["sDefaultBrowserTestURL"] or sArgument for sArgument in gdApplication_asDefaultOptionalArguments_by_sKeyword.get( sApplicationKeyword, []) ] asApplicationArguments = asApplicationStaticArguments + asApplicationOptionalArguments # Apply application specific settings if sApplicationKeyword in gdApplication_dxSettings_by_sKeyword: if not gbQuiet: oConsole.fPrint( "* Applying application specific configuration for %s:" % sApplicationKeyword) for (sSettingName, xValue) in gdApplication_dxSettings_by_sKeyword[ sApplicationKeyword].items(): if sSettingName not in dxUserProvidedConfigSettings: fApplyConfigSetting(sSettingName, xValue, " ") # Apply and show result indented. if not gbQuiet: oConsole.fPrint() # Apply application specific source settings if sApplicationKeyword in gdApplication_sURLTemplate_by_srSourceFilePath_by_sKeyword: dsURLTemplate_by_srSourceFilePath = gdApplication_sURLTemplate_by_srSourceFilePath_by_sKeyword[ sApplicationKeyword] # Apply application specific stdio settings: if sApplicationKeyword in gdApplication_rImportantStdOutLines_by_sKeyword: rImportantStdOutLines = gdApplication_rImportantStdOutLines_by_sKeyword[ sApplicationKeyword] if sApplicationKeyword in gdApplication_rImportantStdErrLines_by_sKeyword: rImportantStdErrLines = gdApplication_rImportantStdErrLines_by_sKeyword[ sApplicationKeyword] if not sApplicationISA and sApplicationKeyword in gdApplication_sISA_by_sKeyword: # Apply application specific ISA sApplicationISA = gdApplication_sISA_by_sKeyword[ sApplicationKeyword] else: # There are no static arguments if there is no application keyword, only the user-supplied optional arguments # are used if they are supplied: asApplicationArguments = asApplicationOptionalArguments or [] # Apply user provided settings: for (sSettingName, xValue) in dxUserProvidedConfigSettings.items(): fApplyConfigSetting(sSettingName, xValue, "") # Apply and show result if bRepeat: duNumberOfRepros_by_sBugIdAndLocation = {} sValidStatisticsFileName = FileSystem.fsValidName( "Reproduction statistics.txt") uRunCounter = 0 while 1: # Will only loop if bRepeat is True nStartTime = time.clock() uRunCounter += 1 if sApplicationBinaryPath: if not gbQuiet: asCommandLine = [sApplicationBinaryPath ] + asApplicationArguments oConsole.fPrint("* Command line: ", INFO, " ".join(asCommandLine)) oConsole.fPrint() oConsole.fStatus("* The debugger is starting the application...") else: if auApplicationProcessIds: asProcessIdsOutput = [] for uApplicationProcessId in auApplicationProcessIds: if asProcessIdsOutput: asProcessIdsOutput.append(", ") asProcessIdsOutput.extend( [INFO, str(uApplicationProcessId), NORMAL]) oConsole.fPrint("* Running process ids: ", INFO, *asProcessIdsOutput) if sApplicationPackageName: if not gbQuiet: if asApplicationArguments: oConsole.fPrint("* Package name: ", INFO, sApplicationPackageName, NORMAL, ", Arguments: ", INFO, " ".join(asApplicationArguments)) else: oConsole.fPrint("* Package name: ", INFO, sApplicationPackageName) oConsole.fPrint() if not sApplicationPackageName: oConsole.fStatus( "* The debugger is attaching to running processes of the application..." ) elif auApplicationProcessIds: oConsole.fStatus( "* The debugger is attaching to running processes and starting the application..." ) else: oConsole.fStatus( "* The debugger is starting the application...") oBugId = cBugId( sCdbISA=sApplicationISA or cBugId.sOSISA, sApplicationBinaryPath=sApplicationBinaryPath or None, auApplicationProcessIds=auApplicationProcessIds or None, sApplicationPackageName=sApplicationPackageName or None, sApplicationId=sApplicationId or None, asApplicationArguments=asApplicationArguments, asLocalSymbolPaths=dxConfig["asLocalSymbolPaths"], asSymbolCachePaths=dxConfig["asSymbolCachePaths"], asSymbolServerURLs=dxConfig["asSymbolServerURLs"], dsURLTemplate_by_srSourceFilePath=dsURLTemplate_by_srSourceFilePath, rImportantStdOutLines=rImportantStdOutLines, rImportantStdErrLines=rImportantStdErrLines, bGenerateReportHTML=dxConfig["bGenerateReportHTML"], fFailedToDebugApplicationCallback=fFailedToDebugApplicationHandler, fApplicationRunningCallback=fApplicationRunningHandler, fApplicationSuspendedCallback=fApplicationSuspendedHandler, fApplicationResumedCallback=fApplicationResumedHandler, fMainProcessTerminatedCallback=fMainProcessTerminatedHandler, fInternalExceptionCallback=fInternalExceptionHandler, fFinishedCallback=None, fPageHeapNotEnabledCallback=fPageHeapNotEnabledHandler, fStdErrOutputCallback=fStdErrOutputHandler, fNewProcessCallback=fNewProcessHandler, ) if dxConfig["nApplicationMaxRunTime"] is not None: oBugId.fxSetTimeout(dxConfig["nApplicationMaxRunTime"], fApplicationRunTimeoutHandler, oBugId) if dxConfig["bExcessiveCPUUsageCheckEnabled"] and dxConfig[ "nExcessiveCPUUsageCheckInitialTimeout"]: oBugId.fSetCheckForExcessiveCPUUsageTimeout( dxConfig["nExcessiveCPUUsageCheckInitialTimeout"]) oBugId.fStart() oBugId.fWait() if gbAnErrorOccured: return 3 if oBugId.oBugReport is not None: oConsole.fPrint(HILITE, "A bug was detect in the application:") oConsole.fPrint(" Id @ Location: ", INFO, oBugId.oBugReport.sId, NORMAL, " @ ", INFO, oBugId.oBugReport.sBugLocation) if oBugId.oBugReport.sBugSourceLocation: oConsole.fPrint(" Source: ", INFO, oBugId.oBugReport.sBugSourceLocation) oConsole.fPrint(" Description: ", INFO, oBugId.oBugReport.sBugDescription) oConsole.fPrint(" Security impact: ", INFO, oBugId.oBugReport.sSecurityImpact) oConsole.fPrint(" Version: ", HILITE, oBugId.oBugReport.asVersionInformation[0]) # There is always the process' binary. for sVersionInformation in oBugId.oBugReport.asVersionInformation[ 1:]: # There may be two if the crash was in a oConsole.fPrint(" ", sVersionInformation) # different binary (e.g. a .dll) sBugIdAndLocation = "%s @ %s" % (oBugId.oBugReport.sId, oBugId.oBugReport.sBugLocation) if dxConfig["bGenerateReportHTML"]: # We'd like a report file name base on the BugId, but the later may contain characters that are not valid in a file name sDesiredReportFileName = "%s.html" % sBugIdAndLocation # Thus, we need to translate these characters to create a valid filename that looks very similar to the BugId sValidReportFileName = FileSystem.fsValidName( sDesiredReportFileName, bUnicode=dxConfig["bUseUnicodeReportFileNames"]) if dxConfig["sReportFolderPath"] is not None: sReportFilePath = FileSystem.fsPath( dxConfig["sReportFolderPath"], sValidReportFileName) else: sReportFilePath = FileSystem.fsPath(sValidReportFileName) eWriteDataToFileResult = FileSystem.feWriteDataToFile( oBugId.oBugReport.sReportHTML, sReportFilePath, fbRetryOnFailure=lambda: False, ) if eWriteDataToFileResult: oConsole.fPrint( " Bug report: ", ERROR, "Cannot be saved (%s)" % repr(eWriteDataToFileResult)) else: oConsole.fPrint( " Bug report: ", HILITE, sValidReportFileName, NORMAL, " (%d bytes)" % len(oBugId.oBugReport.sReportHTML)) else: oConsole.fPrint( 10, "The application terminated without a bug being detected.") sBugIdAndLocation = "No crash" oConsole.fPrint(" Application time: %s seconds" % (long(oBugId.fnApplicationRunTime() * 1000) / 1000.0)) nOverheadTime = time.clock( ) - nStartTime - oBugId.fnApplicationRunTime() oConsole.fPrint(" BugId overhead: %s seconds" % (long(nOverheadTime * 1000) / 1000.0)) if not bRepeat: return oBugId.oBugReport is not None and 1 or 0 duNumberOfRepros_by_sBugIdAndLocation.setdefault(sBugIdAndLocation, 0) duNumberOfRepros_by_sBugIdAndLocation[sBugIdAndLocation] += 1 sStatistics = "" auOrderedNumberOfRepros = sorted( list(set(duNumberOfRepros_by_sBugIdAndLocation.values()))) auOrderedNumberOfRepros.reverse() for uNumberOfRepros in auOrderedNumberOfRepros: for sBugIdAndLocation in duNumberOfRepros_by_sBugIdAndLocation.keys( ): if duNumberOfRepros_by_sBugIdAndLocation[ sBugIdAndLocation] == uNumberOfRepros: sStatistics += "%d \xD7 %s (%d%%)\r\n" % ( uNumberOfRepros, sBugIdAndLocation, round(100.0 * uNumberOfRepros / uRunCounter)) if dxConfig["sReportFolderPath"] is not None: sStatisticsFilePath = FileSystem.fsPath( dxConfig["sReportFolderPath"], sValidStatisticsFileName) else: sStatisticsFilePath = FileSystem.fsPath(sValidStatisticsFileName) eWriteDataToFileResult = FileSystem.feWriteDataToFile( sStatistics, sStatisticsFilePath, fbRetryOnFailure=lambda: False, ) if eWriteDataToFileResult: oConsole.fPrint( " Statistics: ", ERROR, "Cannot be saved (%s)" % repr(eWriteDataToFileResult)) else: oConsole.fPrint(" Statistics: ", INFO, sStatisticsFilePath, NORMAL, " (%d bytes)" % len(sStatistics)) oConsole.fPrint()
def set_page(self, url, page_contents): url = re.sub('^(http://|https://)?', '', url) url = quote(url) # Creates a directory and paste the contents into a file. FileSystem.set_data(url, page_contents)
import config, FileSystem, os, sys, Memory interface = FileSystem.FileSystemOperations() client = Memory.client MemoryOps = Memory.Operations() for i in range(int(sys.argv[1])): os.system('gnome-terminal -e \"python server_stub.py ' + str(8000 + i) + '\"') #GET SERVER PID # pid_table = os.popen(r'ps a | grep "stub"').readlines() # pid_num = [] # for entry in pid_table: # if entry.find('server_stub.py') != -1: pid_num.append(entry) # for index in range(len(pid_num)): pid_num[index] = pid_num[index].split(" ")[0] raid_mode = int(input('Please input raid mode (1 for RAID-1, 5 for RAID-5): ')) FileSystem.Initialize_My_FileSystem(int(sys.argv[1]), raid_mode) while True: command_str = raw_input("$ ") raw_command_list = command_str.split(' ', 1) command = raw_command_list[0] if command == 'write': try: data = command_str[command_str.index('"') + 1:command_str[command_str.index('"') + 1:].index('"') + command_str.index('"') + 1] command_str = command_str.replace('"' + data + '"', "", 1) argv = command_str.split(" ") while bool(argv.count('')): argv.remove('')
def customSetupWorkspace(self, node): print("Setting up workspaces for package [%s]" % node._name) self.cleanBuildWorkspace(node) Utilities.mkdir(FileSystem.getDirectory(FileSystem.WORKING, self._config, node._name)) self.loadDependencies(node)
def start_SyncCFT(self): self.packetmanager = PacketManager() self.security = Security() self.fsystem = FileSystem(self.folder, '.private') (self.privateKey,self.publicKey) = self.security.generate_keys(1024) self.publicKey_plaintext = self.security.export_key(self.publicKey) self.fsystem.start_thread(timeout=1) try: while not self.exit_flag: time.sleep(5) except Exception: pass print self.fsystem.current_dic self.fsystem.terminate_thread() ''' print "\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" print "Here comes our new coding!!\n" mylist = ['FIL?f1?5?1330560662?5310dab750cabf7e2d1f307554874f9a','RMF?f3?11?1339999999?a73c45107081c08dd4560206b8ef8205'] print "The difference of the manifests are..." print self.fsystem.get_diff_manifest_remote(mylist) print "\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" print self.fsystem.current_dic self.fsystem.terminate_thread() pwdA= 'passwordA' (privateKA,publicKA) = self.security.generate_keys(1024) exp_publicKA = self.security.export_key(publicKA) hash_A = self.security.calculate_key_hash(exp_publicKA, pwdA) #(privateKB,publicKB) = self.security.generate_keys(1024) print "Creating the packet..." self.packetmanager.create_packet(2, ['SEC'], 0xabcd,0xfeea, 0xfee0, 3150765550, 286331153, "HELLO", "REQUEST", None, None) self.packetmanager.append_entry_to_TLVlist('SECURITY', exp_publicKA+'?'+hash_A) packet = self.packetmanager.build_packet() #self.packetmanager.append_list_to_TLVlist('DATA', ['oneeeeee','twoooooooo','threeeeeeee', 'fourrrrrrr']) #self.packetmanager.append_entry_to_TLVlist('DATA', 'data_test') #self.packetmanager.append_entry_to_TLVlist('CONTROL', 'control_test') #self.packetmanager.append_entry_to_TLVlist('SECURITY', 'security_test') #packet = self.packetmanager.build_packet() print "This is the packet dump" self.packetmanager.hex_packet() #raw_data = '\x29\x02\xAB\xCD\xFE\xEA\xFE\xE0\xBB\xCC\xDD\xEE\x11\x11\x11\x11\x01\x01\x4C\xA9\x02\x30\x30\x30\x38\x6F\x6E\x65\x65\x65\x65\x65\x65\x02\x30\x30\x31\x30\x74\x77\x6F\x6F\x6F\x6F\x6F\x6F\x6F\x6F\xFF\x30\x30\x31\x31\x74\x68\x72\x65\x65\x65\x65\x65\x65\x65\x65' #raw_packet = self.packetmanager.create_packet(rawdata = raw_data) print "\n\n\n" print self.packetmanager.get_version() print self.packetmanager.get_flags() print self.packetmanager.get_senderID() print self.packetmanager.get_txlocalID() print self.packetmanager.get_txremoteID() print self.packetmanager.get_sequence() print self.packetmanager.get_ack() print self.packetmanager.get_otype() print self.packetmanager.get_ocode() print "This is the TLV_List" print self.packetmanager.get_TLVlist() print "This is the get_TLVlist_typevalue" print self.packetmanager.get_TLVlist_typevalue() print "self.packetmanager.get_TLVlist('SECURITY')" print self.packetmanager.get_TLVlist('SECURITY') security_payload = self.packetmanager.get_TLVlist('SECURITY') recovered_plaintextkey = security_payload[0].split('?')[0] recovered_hash = security_payload[0].split('?')[1] recovered_key = self.security.import_key(recovered_plaintextkey) print recovered_key if self.security.calculate_key_hash(recovered_plaintextkey, pwdA) == recovered_hash: print "Access granted!" ''' ''' original_packet = packet[:] print "\n\n\n*********************************************************\n\n\n" print "The following reprensents a communication between 2 peers" password_A= 'ProtocolDesign' password_B= 'ProtocolDesig' (privateKA,publicKA) = self.security.generate_keys(1024) (privateKB,publicKB) = self.security.generate_keys(1024) print "Peer-A wants to send" self.print_hex(original_packet) print "Peer-A encrypts with Public_Key_B" encrypted_packet = self.security.encrypt(publicKB, original_packet) self.print_hex(encrypted_packet) print "Peer-B decrypts with Private_Key_B" decrypted_packet = self.security.decrypt(privateKB, encrypted_packet) self.print_hex(decrypted_packet) if original_packet == decrypted_packet: print "Both packets are the same after the crypto!!!" #This is the hash sent by A exp_publicKA = self.security.export_key(publicKA) hash_A = self.security.calculate_key_hash(exp_publicKA, password_A) #B calculates the following hash_B = self.security.calculate_key_hash(exp_publicKA, password_A) if hash_A == hash_B: print "Access granted!" else: print "Wrong password!" ''' return
def fsFirstExistingFile(*asPossiblePaths): for sPossiblePath in asPossiblePaths: if sPossiblePath and FileSystem.fbIsFile(sPossiblePath): return sPossiblePath; return None;
def fuMain(asArguments): nStartTime = time.clock() # returns an exit code, values are: # 0 = executed successfully, no bugs found. # 1 = executed successfully, bug detected. # 2 = bad arguments # 3 = internal error # 4 = failed to start process or attach to process(es). # Parse all "--" arguments until we encounter a non-"--" argument. auApplicationProcessIds = [] sApplicationISA = None bForever = False dxUserProvidedConfigSettings = {} while asArguments and asArguments[0].startswith("--"): sArgument = asArguments.pop(0) if "=" in sArgument: sSettingName, sValue = sArgument[2:].split("=", 1) else: # "--bFlag" is an alias for "--bFlag=true" sSettingName = sArgument[2:] sValue = True if sSettingName in ["pid", "pids"]: auApplicationProcessIds += [long(x) for x in sValue.split(",")] elif sSettingName == "isa": if sValue not in ["x86", "x64"]: print "- Unknown ISA %s" % repr(sValue) return 2 sApplicationISA = sValue elif sSettingName == "fast": # Alias for these three settings: dxUserProvidedConfigSettings["bGenerateReportHTML"] = False dxUserProvidedConfigSettings["asSymbolServerURLs"] = [] dxUserProvidedConfigSettings["cBugId.bUse_NT_SYMBOL_PATH"] = False elif sSettingName == "forever": bForever = True else: try: xValue = json.loads(sValue) except ValueError: print "- Cannot decode argument JSON value %s" % sValue return 2 # User provided config settings must be applied after any keyword specific config settings: dxUserProvidedConfigSettings[sSettingName] = xValue dsURLTemplate_by_srSourceFilePath = {} rImportantStdOutLines = None rImportantStdErrLines = None # If there are any additional arguments, it must be an application keyword followed by additional arguments # or an application command-line: if not asArguments: # No keyword or command line: process ids to attach to must be provided asApplicationCommandLine = None if not auApplicationProcessIds: print "You must specify an application command-line, keyword or process ids" return 2 else: # First argument may be an application keyword sApplicationKeyword = None sApplicationBinary = None if "=" in asArguments[0]: # user provided an application keyword and binary sApplicationKeyword, sApplicationBinary = asArguments.pop(0).split( "=", 1) elif asArguments[0] in asApplicationKeywords or asArguments[0][ -1] == "?": # user provided an application keyword, or requested information on something that may be one: sApplicationKeyword = asArguments.pop(0) asApplicationCommandLine = None if sApplicationKeyword: if sApplicationKeyword[-1] == "?": # User requested information about a possible keyword application return fuShowApplicationKeyWordHelp(sApplicationKeyword[:-1]) # Get application command line for keyword, if available: if sApplicationKeyword in gdApplication_asCommandLine_by_sKeyword: if auApplicationProcessIds: print "You cannot specify process ids for application %s" % sApplicationKeyword return 2 asApplicationCommandLine = gdApplication_asCommandLine_by_sKeyword[ sApplicationKeyword] if sApplicationBinary: # Replace binary with user provided value asApplicationCommandLine = [ sApplicationBinary ] + asApplicationCommandLine[1:] else: if asApplicationCommandLine[0] is None: print "Application %s does not appear to be installed" return 2 if asArguments: # Add user provided additional application arguments: asApplicationCommandLine += asArguments elif sApplicationKeyword in gdApplication_asDefaultAdditionalArguments_by_sKeyword: # Add default additional application arguments: asApplicationCommandLine += [ sArgument is DEFAULT_BROWSER_TEST_URL and dxConfig["sDefaultBrowserTestURL"] or sArgument for sArgument in gdApplication_asDefaultAdditionalArguments_by_sKeyword[ sApplicationKeyword] ] elif asArguments: print "You cannot specify arguments for application keyword %s" % sApplicationKeyword return 2 elif not auApplicationProcessIds: print "You must specify process ids for application keyword %s" % sApplicationKeyword return 2 # Apply application specific settings if sApplicationKeyword in gdApplication_dxSettings_by_sKeyword: print "* Applying application specific settings:" for (sSettingName, xValue) in gdApplication_dxSettings_by_sKeyword[ sApplicationKeyword].items(): if sSettingName not in dxUserProvidedConfigSettings: fApplyConfigSetting(sSettingName, xValue, " ") # Apply and show result indented. # Apply application specific source settings if sApplicationKeyword in gdApplication_sURLTemplate_by_srSourceFilePath_by_sKeyword: dsURLTemplate_by_srSourceFilePath = gdApplication_sURLTemplate_by_srSourceFilePath_by_sKeyword[ sApplicationKeyword] # Apply application specific stdio settings: if sApplicationKeyword in gdApplication_rImportantStdOutLines_by_sKeyword: rImportantStdOutLines = gdApplication_rImportantStdOutLines_by_sKeyword[ sApplicationKeyword] if sApplicationKeyword in gdApplication_rImportantStdErrLines_by_sKeyword: rImportantStdErrLines = gdApplication_rImportantStdErrLines_by_sKeyword[ sApplicationKeyword] if not sApplicationISA and sApplicationKeyword in gdApplication_sISA_by_sKeyword: # Apply application specific ISA sApplicationISA = gdApplication_sISA_by_sKeyword[ sApplicationKeyword] elif auApplicationProcessIds: # user provided an application command-line and process ids print "You cannot specify both an application command-line and process ids" return 2 else: # user provided an application command-line asApplicationCommandLine = asArguments # Apply user provided settings: for (sSettingName, xValue) in dxUserProvidedConfigSettings.items(): fApplyConfigSetting(sSettingName, xValue) # Apply and show result while 1: # Will only loop if bForever is True if asApplicationCommandLine: print "+ The debugger is starting the application..." print " Command line: %s" % " ".join(asApplicationCommandLine) else: print "+ The debugger is attaching to the application..." oBugId = cBugId( sCdbISA=sApplicationISA or cBugId.sOSISA, asApplicationCommandLine=asApplicationCommandLine or None, auApplicationProcessIds=auApplicationProcessIds or None, asLocalSymbolPaths=dxConfig["asLocalSymbolPaths"], asSymbolCachePaths=dxConfig["asSymbolCachePaths"], asSymbolServerURLs=dxConfig["asSymbolServerURLs"], dsURLTemplate_by_srSourceFilePath=dsURLTemplate_by_srSourceFilePath, rImportantStdOutLines=rImportantStdOutLines, rImportantStdErrLines=rImportantStdErrLines, bGenerateReportHTML=dxConfig["bGenerateReportHTML"], fApplicationRunningCallback=fApplicationRunningHandler, fApplicationSuspendedCallback=fApplicationSuspendedHandler, fApplicationResumedCallback=fApplicationResumedHandler, fMainProcessTerminatedCallback=fMainProcessTerminatedHandler, ) if dxConfig["nApplicationMaxRunTime"] is not None: oBugId.fxSetTimeout(dxConfig["nApplicationMaxRunTime"], fApplicationRunTimeoutHandler, oBugId) if dxConfig["nExcessiveCPUUsageCheckInitialTimeout"]: oBugId.fSetCheckForExcessiveCPUUsageTimeout( dxConfig["nExcessiveCPUUsageCheckInitialTimeout"]) oBugId.fStart() oBugId.fWait() if oBugId.oInternalException: print "-" * 80 print "- An error has occured in cBugId, which cannot be handled:" print " %s" % repr(oBugId.oInternalException) print " BugId version %s, cBugId version %s" % (sVersion, cBugId.sVersion) print "-" * 80 print print " Please report this issue at the below web-page so it can be addressed:" print " https://github.com/SkyLined/BugId/issues/new" print " If you do not have a github account, or you want to report this issue" print " privately, you can also send an email to:" print " [email protected]" print print " In your report, please copy all the information about the error reported" print " above, as well as the version information. This makes it easier to determine" print " the cause of this issue. I will try to address the issues as soon as" print " possible. Thank you in advance for helping to improve BugId!" return 3 if oBugId.sFailedToDebugApplicationErrorMessage is not None: print "-" * 80 print "- Failed to debug the application:" for sLine in oBugId.sFailedToDebugApplicationErrorMessage.split( "\n"): print " %s" % sLine.rstrip("\r") print "-" * 80 return 4 if oBugId.oBugReport is not None: print print " === BugId report (https://github.com/SkyLined/BugId) ".ljust( 80, "=") print " Id: %s" % oBugId.oBugReport.sId print " Location: %s" % oBugId.oBugReport.sBugLocation print " Description: %s" % oBugId.oBugReport.sBugDescription print " Version: %s" % oBugId.oBugReport.asVersionInformation[ 0] # There is always the process' binary. for sVersionInformation in oBugId.oBugReport.asVersionInformation[ 1:]: # There may be two if the crash was in a print " %s" % sVersionInformation # different binary (e.g. a .dll) if oBugId.oBugReport.sBugSourceLocation: print " Source: %s" % oBugId.oBugReport.sBugSourceLocation print " Security impact: %s" % oBugId.oBugReport.sSecurityImpact print " Application time: %s seconds" % ( long(oBugId.fnApplicationRunTime() * 1000) / 1000.0) nOverheadTime = time.clock( ) - nStartTime - oBugId.fnApplicationRunTime() print " BugId overhead: %s seconds" % ( long(nOverheadTime * 1000) / 1000.0) if dxConfig["bGenerateReportHTML"]: # We'd like a report file name base on the BugId, but the later may contain characters that are not valid in a file name sDesiredReportFileName = "%s @ %s.html" % ( oBugId.oBugReport.sId, oBugId.oBugReport.sBugLocation) # Thus, we need to translate these characters to create a valid filename that looks very similar to the BugId sValidReportFileName = FileSystem.fsValidName( sDesiredReportFileName, bUnicode=dxConfig["bUseUnicodeReportFileNames"]) if dxConfig["sReportFolderPath"] is not None: sReportFilePath = FileSystem.fsPath( dxConfig["sReportFolderPath"], sValidReportFileName) else: sReportFilePath = FileSystem.fsPath(sValidReportFileName) eWriteDataToFileResult = FileSystem.feWriteDataToFile( oBugId.oBugReport.sReportHTML, sReportFilePath, fbRetryOnFailure=lambda: False, ) if eWriteDataToFileResult: print " Bug report: Cannot be saved (%s)" % repr( eWriteDataToFileResult) else: print " Bug report: %s (%d bytes)" % ( sValidReportFileName, len( oBugId.oBugReport.sReportHTML)) if not bForever: return 1 else: print print " === BugId report (https://github.com/SkyLined/BugId) ".ljust( 80, "=") print " Id: None" print " Description: The application terminated before a bug was detected." print " Application time: %s seconds" % ( long(oBugId.fnApplicationRunTime() * 1000) / 1000.0) nOverheadTime = time.clock( ) - nStartTime - oBugId.fnApplicationRunTime() print " BugId overhead: %s seconds" % ( long(nOverheadTime * 1000) / 1000.0) if not bForever: return 0 print
oBugId.fWait(); if oBugId.oBugReport: print "+ A bug was detected in the application."; print; print " Id: %s" % oBugId.oBugReport.sId; print " Description: %s" % oBugId.oBugReport.sBugDescription; print " Location: %s" % oBugId.oBugReport.sBugLocation; if oBugId.oBugReport.sBugSourceLocation: print " Source: %s" % oBugId.oBugReport.sBugSourceLocation; print " Security impact: %s" % oBugId.oBugReport.sSecurityImpact; print " Run time: %s seconds" % (long(oBugId.fnApplicationRunTime() * 1000) / 1000.0); if dxConfig["bSaveReport"]: # We'd like a report file name base on the BugId, but the later may contain characters that are not valid in a file name sDesiredReportFileName = "%s @ %s.html" % (oBugId.oBugReport.sId, oBugId.oBugReport.sBugLocation); # Thus, we need to translate these characters to create a valid filename that looks very similar to the BugId sValidReportFileName = FileSystem.fsTranslateToValidName(sDesiredReportFileName, bUnicode = dxConfig["bUseUnicodeReportFileNames"]); eWriteDataToFileResult = FileSystem.feWriteDataToFile( oBugId.oBugReport.sDetailsHTML, FileSystem.fsLocalPath(sValidReportFileName), fbRetryOnFailure = lambda: False, ); if eWriteDataToFileResult: print " Bug report: Cannot be saved (%s)" % repr(eWriteDataToFileResult); else: print " Bug report: %s (%d bytes)" % (sValidReportFileName, len(oBugId.oBugReport.sDetailsHTML)); else: print "- The application has terminated without crashing."; print " Run time: %s seconds" % (long(oBugId.fnApplicationRunTime() * 1000) / 1000.0); if dxConfig["bShowLincenseAndDonationInfo"]: print;
import FileSystem import time FileSystem.Initialize_My_FileSystem() fs = FileSystem.FileSystemOperations() fsexit = 0 print("RAID5") while fsexit == 0: command = raw_input("$ ") command = command.split() try: if command[0] == "mkdir": fs.mkdir(command[1]) elif command[0] == "create": fs.create(command[1]) elif command[0] == "write": path = command[1] data = command[2:len(command) - 1] data = ' '.join(str(item) for item in data) offset = command[len(command) - 1] start = time.clock() fs.write(str(path), str(data), int(offset)) end = time.clock() #print("Time taken to perform write:", end - start) elif command[0] == "read": path = command[1] offset = command[2] size = command[3] start = time.clock() fs.read(path, int(offset), int(size)) end = time.clock()
class SyncCFT: def __init__(self): signal.signal(signal.SIGINT, self.signal_handler) self.logger = logging.getLogger("SyncCFT 1.0") self.logger.info("Starting SyncCFT 1.0 at %s" % (str(time.time()))) self.exit_flag = 0 config = Configuration(sys.argv) conf_values = config.load_configuration() self.local_password = config.load_password() if not conf_values: self.logger.error("An error occurred while loading the configuration!") return (self.port, self.folder, self.p_prob, self.q_prob, self.peers) = conf_values #Logging of configuration self.logger.info("Listening on UDP port %s" % (str(self.port))) self.logger.info("Synchronizing folder %s" % (str(self.folder))) self.logger.info("'p' parameter: %s" % (str(self.p_prob))) self.logger.info("'q' parameter: %s" % (str(self.q_prob))) i=1 for item in self.peers: self.logger.info("Peer %d: %s:%s" % (i,str(item[0]),str(item[1]))) i+=1 def start_SyncCFT(self): self.packetmanager = PacketManager() self.security = Security() self.fsystem = FileSystem(self.folder, '.private') (self.privateKey,self.publicKey) = self.security.generate_keys(1024) self.publicKey_plaintext = self.security.export_key(self.publicKey) self.fsystem.start_thread(timeout=1) try: while not self.exit_flag: time.sleep(5) except Exception: pass print self.fsystem.current_dic self.fsystem.terminate_thread() ''' print "\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" print "Here comes our new coding!!\n" mylist = ['FIL?f1?5?1330560662?5310dab750cabf7e2d1f307554874f9a','RMF?f3?11?1339999999?a73c45107081c08dd4560206b8ef8205'] print "The difference of the manifests are..." print self.fsystem.get_diff_manifest_remote(mylist) print "\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" print self.fsystem.current_dic self.fsystem.terminate_thread() pwdA= 'passwordA' (privateKA,publicKA) = self.security.generate_keys(1024) exp_publicKA = self.security.export_key(publicKA) hash_A = self.security.calculate_key_hash(exp_publicKA, pwdA) #(privateKB,publicKB) = self.security.generate_keys(1024) print "Creating the packet..." self.packetmanager.create_packet(2, ['SEC'], 0xabcd,0xfeea, 0xfee0, 3150765550, 286331153, "HELLO", "REQUEST", None, None) self.packetmanager.append_entry_to_TLVlist('SECURITY', exp_publicKA+'?'+hash_A) packet = self.packetmanager.build_packet() #self.packetmanager.append_list_to_TLVlist('DATA', ['oneeeeee','twoooooooo','threeeeeeee', 'fourrrrrrr']) #self.packetmanager.append_entry_to_TLVlist('DATA', 'data_test') #self.packetmanager.append_entry_to_TLVlist('CONTROL', 'control_test') #self.packetmanager.append_entry_to_TLVlist('SECURITY', 'security_test') #packet = self.packetmanager.build_packet() print "This is the packet dump" self.packetmanager.hex_packet() #raw_data = '\x29\x02\xAB\xCD\xFE\xEA\xFE\xE0\xBB\xCC\xDD\xEE\x11\x11\x11\x11\x01\x01\x4C\xA9\x02\x30\x30\x30\x38\x6F\x6E\x65\x65\x65\x65\x65\x65\x02\x30\x30\x31\x30\x74\x77\x6F\x6F\x6F\x6F\x6F\x6F\x6F\x6F\xFF\x30\x30\x31\x31\x74\x68\x72\x65\x65\x65\x65\x65\x65\x65\x65' #raw_packet = self.packetmanager.create_packet(rawdata = raw_data) print "\n\n\n" print self.packetmanager.get_version() print self.packetmanager.get_flags() print self.packetmanager.get_senderID() print self.packetmanager.get_txlocalID() print self.packetmanager.get_txremoteID() print self.packetmanager.get_sequence() print self.packetmanager.get_ack() print self.packetmanager.get_otype() print self.packetmanager.get_ocode() print "This is the TLV_List" print self.packetmanager.get_TLVlist() print "This is the get_TLVlist_typevalue" print self.packetmanager.get_TLVlist_typevalue() print "self.packetmanager.get_TLVlist('SECURITY')" print self.packetmanager.get_TLVlist('SECURITY') security_payload = self.packetmanager.get_TLVlist('SECURITY') recovered_plaintextkey = security_payload[0].split('?')[0] recovered_hash = security_payload[0].split('?')[1] recovered_key = self.security.import_key(recovered_plaintextkey) print recovered_key if self.security.calculate_key_hash(recovered_plaintextkey, pwdA) == recovered_hash: print "Access granted!" ''' ''' original_packet = packet[:] print "\n\n\n*********************************************************\n\n\n" print "The following reprensents a communication between 2 peers" password_A= 'ProtocolDesign' password_B= 'ProtocolDesig' (privateKA,publicKA) = self.security.generate_keys(1024) (privateKB,publicKB) = self.security.generate_keys(1024) print "Peer-A wants to send" self.print_hex(original_packet) print "Peer-A encrypts with Public_Key_B" encrypted_packet = self.security.encrypt(publicKB, original_packet) self.print_hex(encrypted_packet) print "Peer-B decrypts with Private_Key_B" decrypted_packet = self.security.decrypt(privateKB, encrypted_packet) self.print_hex(decrypted_packet) if original_packet == decrypted_packet: print "Both packets are the same after the crypto!!!" #This is the hash sent by A exp_publicKA = self.security.export_key(publicKA) hash_A = self.security.calculate_key_hash(exp_publicKA, password_A) #B calculates the following hash_B = self.security.calculate_key_hash(exp_publicKA, password_A) if hash_A == hash_B: print "Access granted!" else: print "Wrong password!" ''' return def signal_handler(self, signal, frame): self.logger.warning("You pressed Ctrl+C") print "\nYou pressed Ctrl+C!\n" self.exit_flag = 1 #sys.exit(1) def print_hex(self, text): l = len(text) i = 0 while i < l: print "%04x " % i, for j in range(16): if i+j < l: print "%02X" % ord(text[i+j]), else: print " ", if j%16 == 7: print "", print " ", ascii = text[i:i+16] r="" for i2 in ascii: j2 = ord(i2) if (j2 < 32) or (j2 >= 127): r=r+"." else: r=r+i2 print r i += 16
def fuMain(asArguments): nStartTime = time.clock(); # returns an exit code, values are: # 0 = executed successfully, no bugs found. # 1 = executed successfully, bug detected. # 2 = bad arguments # 3 = internal error # 4 = failed to start process or attach to process(es). # Parse all "--" arguments until we encounter a non-"--" argument. auApplicationProcessIds = []; sApplicationISA = None; bForever = False; dxUserProvidedConfigSettings = {}; while asArguments and asArguments[0].startswith("--"): sArgument = asArguments.pop(0); if "=" in sArgument: sSettingName, sValue = sArgument[2:].split("=", 1); else: # "--bFlag" is an alias for "--bFlag=true" sSettingName = sArgument[2:]; sValue = True; if sSettingName in ["pid", "pids"]: auApplicationProcessIds += [long(x) for x in sValue.split(",")]; elif sSettingName == "isa": if sValue not in ["x86", "x64"]: print "- Unknown ISA %s" % repr(sValue); return 2; sApplicationISA = sValue; elif sSettingName == "fast": # Alias for these three settings: dxUserProvidedConfigSettings["bGenerateReportHTML"] = False; dxUserProvidedConfigSettings["asSymbolServerURLs"] = []; dxUserProvidedConfigSettings["cBugId.bUse_NT_SYMBOL_PATH"] = False; elif sSettingName == "forever": bForever = True; else: try: xValue = json.loads(sValue); except ValueError: print "- Cannot decode argument JSON value %s" % sValue; return 2; # User provided config settings must be applied after any keyword specific config settings: dxUserProvidedConfigSettings[sSettingName] = xValue; dsURLTemplate_by_srSourceFilePath = {}; rImportantStdOutLines = None; rImportantStdErrLines = None; # If there are any additional arguments, it must be an application keyword followed by additional arguments # or an application command-line: if not asArguments: # No keyword or command line: process ids to attach to must be provided asApplicationCommandLine = None; if not auApplicationProcessIds: print "You must specify an application command-line, keyword or process ids"; return 2; else: # First argument may be an application keyword sApplicationKeyword = None; sApplicationBinary = None; if "=" in asArguments[0]: # user provided an application keyword and binary sApplicationKeyword, sApplicationBinary = asArguments.pop(0).split("=", 1); elif asArguments[0] in asApplicationKeywords or asArguments[0][-1] == "?": # user provided an application keyword, or requested information on something that may be one: sApplicationKeyword = asArguments.pop(0); asApplicationCommandLine = None; if sApplicationKeyword: if sApplicationKeyword[-1] == "?": # User requested information about a possible keyword application return fuShowApplicationKeyWordHelp(sApplicationKeyword[:-1]); # Get application command line for keyword, if available: if sApplicationKeyword in gdApplication_asCommandLine_by_sKeyword: if auApplicationProcessIds: print "You cannot specify process ids for application %s" % sApplicationKeyword; return 2; asApplicationCommandLine = gdApplication_asCommandLine_by_sKeyword[sApplicationKeyword]; if sApplicationBinary: # Replace binary with user provided value asApplicationCommandLine = [sApplicationBinary] + asApplicationCommandLine[1:]; else: if asApplicationCommandLine[0] is None: print "Application %s does not appear to be installed"; return 2; if asArguments: # Add user provided additional application arguments: asApplicationCommandLine += asArguments; elif sApplicationKeyword in gdApplication_asDefaultAdditionalArguments_by_sKeyword: # Add default additional application arguments: asApplicationCommandLine += [ sArgument is DEFAULT_BROWSER_TEST_URL and dxConfig["sDefaultBrowserTestURL"] or sArgument for sArgument in gdApplication_asDefaultAdditionalArguments_by_sKeyword[sApplicationKeyword] ]; elif asArguments: print "You cannot specify arguments for application keyword %s" % sApplicationKeyword; return 2; elif not auApplicationProcessIds: print "You must specify process ids for application keyword %s" % sApplicationKeyword; return 2; # Apply application specific settings if sApplicationKeyword in gdApplication_dxSettings_by_sKeyword: print "* Applying application specific settings:"; for (sSettingName, xValue) in gdApplication_dxSettings_by_sKeyword[sApplicationKeyword].items(): if sSettingName not in dxUserProvidedConfigSettings: fApplyConfigSetting(sSettingName, xValue, " "); # Apply and show result indented. # Apply application specific source settings if sApplicationKeyword in gdApplication_sURLTemplate_by_srSourceFilePath_by_sKeyword: dsURLTemplate_by_srSourceFilePath = gdApplication_sURLTemplate_by_srSourceFilePath_by_sKeyword[sApplicationKeyword]; # Apply application specific stdio settings: if sApplicationKeyword in gdApplication_rImportantStdOutLines_by_sKeyword: rImportantStdOutLines = gdApplication_rImportantStdOutLines_by_sKeyword[sApplicationKeyword]; if sApplicationKeyword in gdApplication_rImportantStdErrLines_by_sKeyword: rImportantStdErrLines = gdApplication_rImportantStdErrLines_by_sKeyword[sApplicationKeyword]; if not sApplicationISA and sApplicationKeyword in gdApplication_sISA_by_sKeyword: # Apply application specific ISA sApplicationISA = gdApplication_sISA_by_sKeyword[sApplicationKeyword]; elif auApplicationProcessIds: # user provided an application command-line and process ids print "You cannot specify both an application command-line and process ids"; return 2; else: # user provided an application command-line asApplicationCommandLine = asArguments; # Apply user provided settings: for (sSettingName, xValue) in dxUserProvidedConfigSettings.items(): fApplyConfigSetting(sSettingName, xValue); # Apply and show result while 1: # Will only loop if bForever is True if asApplicationCommandLine: print "+ The debugger is starting the application..."; print " Command line: %s" % " ".join(asApplicationCommandLine); else: print "+ The debugger is attaching to the application..."; oBugId = cBugId( sCdbISA = sApplicationISA or cBugId.sOSISA, asApplicationCommandLine = asApplicationCommandLine or None, auApplicationProcessIds = auApplicationProcessIds or None, asLocalSymbolPaths = dxConfig["asLocalSymbolPaths"], asSymbolCachePaths = dxConfig["asSymbolCachePaths"], asSymbolServerURLs = dxConfig["asSymbolServerURLs"], dsURLTemplate_by_srSourceFilePath = dsURLTemplate_by_srSourceFilePath, rImportantStdOutLines = rImportantStdOutLines, rImportantStdErrLines = rImportantStdErrLines, bGenerateReportHTML = dxConfig["bGenerateReportHTML"], fApplicationRunningCallback = fApplicationRunningHandler, fApplicationSuspendedCallback = fApplicationSuspendedHandler, fApplicationResumedCallback = fApplicationResumedHandler, fMainProcessTerminatedCallback = fMainProcessTerminatedHandler, ); if dxConfig["nApplicationMaxRunTime"] is not None: oBugId.fxSetTimeout(dxConfig["nApplicationMaxRunTime"], fApplicationRunTimeoutHandler, oBugId); if dxConfig["nExcessiveCPUUsageCheckInitialTimeout"]: oBugId.fSetCheckForExcessiveCPUUsageTimeout(dxConfig["nExcessiveCPUUsageCheckInitialTimeout"]); oBugId.fStart(); oBugId.fWait(); if oBugId.oInternalException: print "-" * 80; print "- An error has occured in cBugId, which cannot be handled:"; print " %s" % repr(oBugId.oInternalException); print " BugId version %s, cBugId version %s" % (sVersion, cBugId.sVersion); print "-" * 80; print; print " Please report this issue at the below web-page so it can be addressed:"; print " https://github.com/SkyLined/BugId/issues/new"; print " If you do not have a github account, or you want to report this issue"; print " privately, you can also send an email to:"; print " [email protected]"; print; print " In your report, please copy all the information about the error reported"; print " above, as well as the version information. This makes it easier to determine"; print " the cause of this issue. I will try to address the issues as soon as"; print " possible. Thank you in advance for helping to improve BugId!"; return 3; if oBugId.sFailedToDebugApplicationErrorMessage is not None: print "-" * 80; print "- Failed to debug the application:" for sLine in oBugId.sFailedToDebugApplicationErrorMessage.split("\n"): print " %s" % sLine.rstrip("\r"); print "-" * 80; return 4; if oBugId.oBugReport is not None: print; print " === BugId report (https://github.com/SkyLined/BugId) ".ljust(80, "="); print " Id: %s" % oBugId.oBugReport.sId; print " Location: %s" % oBugId.oBugReport.sBugLocation; print " Description: %s" % oBugId.oBugReport.sBugDescription; print " Version: %s" % oBugId.oBugReport.asVersionInformation[0]; # There is always the process' binary. for sVersionInformation in oBugId.oBugReport.asVersionInformation[1:]: # There may be two if the crash was in a print " %s" % sVersionInformation; # different binary (e.g. a .dll) if oBugId.oBugReport.sBugSourceLocation: print " Source: %s" % oBugId.oBugReport.sBugSourceLocation; print " Security impact: %s" % oBugId.oBugReport.sSecurityImpact; print " Application time: %s seconds" % (long(oBugId.fnApplicationRunTime() * 1000) / 1000.0); nOverheadTime = time.clock() - nStartTime - oBugId.fnApplicationRunTime(); print " BugId overhead: %s seconds" % (long(nOverheadTime * 1000) / 1000.0); if dxConfig["bGenerateReportHTML"]: # We'd like a report file name base on the BugId, but the later may contain characters that are not valid in a file name sDesiredReportFileName = "%s @ %s.html" % (oBugId.oBugReport.sId, oBugId.oBugReport.sBugLocation); # Thus, we need to translate these characters to create a valid filename that looks very similar to the BugId sValidReportFileName = FileSystem.fsValidName(sDesiredReportFileName, bUnicode = dxConfig["bUseUnicodeReportFileNames"]); if dxConfig["sReportFolderPath"] is not None: sReportFilePath = FileSystem.fsPath(dxConfig["sReportFolderPath"], sValidReportFileName); else: sReportFilePath = FileSystem.fsPath(sValidReportFileName); eWriteDataToFileResult = FileSystem.feWriteDataToFile( oBugId.oBugReport.sReportHTML, sReportFilePath, fbRetryOnFailure = lambda: False, ); if eWriteDataToFileResult: print " Bug report: Cannot be saved (%s)" % repr(eWriteDataToFileResult); else: print " Bug report: %s (%d bytes)" % (sValidReportFileName, len(oBugId.oBugReport.sReportHTML)); if not bForever: return 1; else: print; print " === BugId report (https://github.com/SkyLined/BugId) ".ljust(80, "="); print " Id: None"; print " Description: The application terminated before a bug was detected."; print " Application time: %s seconds" % (long(oBugId.fnApplicationRunTime() * 1000) / 1000.0); nOverheadTime = time.clock() - nStartTime - oBugId.fnApplicationRunTime(); print " BugId overhead: %s seconds" % (long(nOverheadTime * 1000) / 1000.0); if not bForever: return 0; print; # and loop