def __create_target_dirs(self): """ Create the output directory. """ if not os.path.isdir(paths.OUTPUT_PATH): try: if not os.path.isdir(paths.OUTPUT_PATH): os.makedirs(paths.OUTPUT_PATH, 0755) warnMsg = "using '%s' as the output directory" % paths.OUTPUT_PATH self.logger.warn(warnMsg) except (OSError, IOError), ex: try: tempDir = tempfile.mkdtemp(prefix="3102output") except Exception, _: errMsg = "unable to write to the temporary directory ('%s'). " % _ errMsg += "Please make sure that your disk is not full and " errMsg += "that you have sufficient write permissions to " errMsg += "create temporary files and/or directories" raise Exception(errMsg) warnMsg = "unable to create regular output directory " warnMsg += "'%s' (%s). " % (paths.OUTPUT_PATH, getUnicode(ex)) warnMsg += "Using temporary directory '%s' instead" % tempDir self.logger.warn(warnMsg) paths.OUTPUT_PATH = tempDir
def _mergeConfOptions(cmdOptions): configFile = paths.CONFIG_FILE_PATH try: # 检查配置文件是否存在 checkFile(configFile) # 检查配置文件格式合法性 config = ConfigParser.ConfigParser() config.read(configFile) except Exception, ex: # FIXME: 这里是 抛出异常,退出程序 还是 提示,然后以默认参数运行会比较好? errMsg = "Invalid/Unreadable configuration file : '%s'" % getUnicode(ex) raise Exception(errMsg)
def modulePath(): """ This will get us the program's directory, even if we are frozen using py2exe Reference from sqlmap. (sqlmapproject/sqlmap)[https://github.com/sqlmapproject/sqlmap] """ try: _ = sys.executable if weAreFrozen() else __file__ except NameError: _ = inspect.getsourcefile(modulePath) return os.path.dirname(os.path.realpath(getUnicode(_, sys.getfilesystemencoding())))
def _mergeConfOptions(cmdOptions): configFile = paths.CONFIG_FILE_PATH try: # 检查配置文件是否存在 checkFile(configFile) # 检查配置文件格式合法性 config = ConfigParser.ConfigParser() config.read(configFile) except Exception, ex: # FIXME: 这里是 抛出异常,退出程序 还是 提示,然后以默认参数运行会比较好? errMsg = "Invalid/Unreadable configuration file : '%s'" % getUnicode( ex) raise Exception(errMsg)
tempDir = tempfile.mkdtemp(prefix="3102output") except Exception, _: errMsg = "unable to write to the temporary directory ('%s'). " % _ errMsg += "Please make sure that your disk is not full and " errMsg += "that you have sufficient write permissions to " errMsg += "create temporary files and/or directories" raise Exception(errMsg) warnMsg = "unable to create regular output directory " warnMsg += "'%s' (%s). " % (paths.OUTPUT_PATH, getUnicode(ex)) warnMsg += "Using temporary directory '%s' instead" % tempDir self.logger.warn(warnMsg) paths.OUTPUT_PATH = tempDir self.outputPath = os.path.join(getUnicode(paths.OUTPUT_PATH), normalizeUnicode(getUnicode(self.domain))) if not os.path.isdir(self.outputPath): try: os.makedirs(self.outputPath, 0755) except (OSError, IOError), ex: try: tempDir = tempfile.mkdtemp(prefix="3102output") except Exception, _: errMsg = "unable to write to the temporary directory ('%s'). " % _ errMsg += "Please make sure that your disk is not full and " errMsg += "that you have sufficient write permissions to " errMsg += "create temporary files and/or directories" raise Exception(errMsg) warnMsg = "unable to create output directory "
except Exception, _: errMsg = "unable to write to the temporary directory ('%s'). " % _ errMsg += "Please make sure that your disk is not full and " errMsg += "that you have sufficient write permissions to " errMsg += "create temporary files and/or directories" raise Exception(errMsg) warnMsg = "unable to create regular output directory " warnMsg += "'%s' (%s). " % (paths.OUTPUT_PATH, getUnicode(ex)) warnMsg += "Using temporary directory '%s' instead" % tempDir self.logger.warn(warnMsg) paths.OUTPUT_PATH = tempDir self.outputPath = os.path.join( getUnicode(paths.OUTPUT_PATH), normalizeUnicode(getUnicode(self.domain))) if not os.path.isdir(self.outputPath): try: os.makedirs(self.outputPath, 0755) except (OSError, IOError), ex: try: tempDir = tempfile.mkdtemp(prefix="3102output") except Exception, _: errMsg = "unable to write to the temporary directory ('%s'). " % _ errMsg += "Please make sure that your disk is not full and " errMsg += "that you have sufficient write permissions to " errMsg += "create temporary files and/or directories" raise Exception(errMsg)
def _mergeOptions(inputOptions, overrideOptions): configFile = paths.CONFIG_FILE_PATH checkFile(configFile) try: config=ConfigParser.ConfigParser() config.read(configFile) except Exception, ex: errMsg = "you have provided an invalid and/or unreadable configuration file ('%s')" % getUnicode(ex) raise Exception(errMsg)