def main(): if settings.get('log:errors'): log_filename = settings.get('log:filename') if log_filename: try: log_file = open(log_filename, "w") print('Redirecting stderr/stdout... to %s' % log_filename) sys.stderr = log_file sys.stdout = log_file except IOError: print "Lector could not open log file '%s'!\n" % log_filename \ + " Redirecting will not work." else: print "Log file is not set. Pleaase set it in settings." app = QApplication(sys.argv) opts = [str(arg) for arg in app.arguments()[1:]] if '--no-scanner' in opts: scanner = False else: scanner = True qsrand(QTime(0, 0, 0).secsTo(QTime.currentTime())) locale = settings.get('ui:lang') if not locale: locale = QLocale.system().name() qtTranslator = QTranslator() if qtTranslator.load(":/translations/ts/lector_" + locale, 'ts'): app.installTranslator(qtTranslator) window = Window(scanner) window.show() app.exec_()
def main(): """Function, executed on start """ # create application app = QApplication (sys.argv) app.setApplicationName( "fresh-examples" ) qsrand( QTime( 0, 0, 0 ).secsTo( QTime.currentTime() ) ) pSettings.setDefaultProperties(pSettings.Properties(app.applicationName(), \ "1.0.0", pSettings.Portable)) window = MainWindow() window.setWindowTitle( app.applicationName() ) window.show() # connection app.lastWindowClosed.connect(app.quit) # start application result = app.exec_() del window return result
def generate_password(charcount, charset, seed): """Generate a password for the given charcount, charset and seed using the qsrand() and qrand() functions, just as the KDE paste applet would. Note that this is an example of how NOT to do it.""" qsrand(seed) return "".join([charset[qrand() % len(charset)] for _ in range(charcount)])
def generate_password(charcount, charset, seed): """Generate a password for the given charcount, charset and seed using the qsrand() and qrand() functions, just as the KDE paste applet would. Note that this is an example of how NOT to do it.""" qsrand(seed) return "".join([ charset[qrand() % len(charset)] for _ in range(charcount)])
def main(): if settings.get('log:errors'): log_filename = settings.get('log:filename') if log_filename: try: log_file = open(log_filename,"w") print ('Redirecting stderr/stdout... to %s' % log_filename) sys.stderr = log_file sys.stdout = log_file except IOError: print "Lector could not open log file '%s'!\n" % log_filename \ + " Redirecting will not work." else: print "Log file is not set. Pleaase set it in settings." app = QApplication(sys.argv) opts = [str(arg) for arg in app.arguments()[1:]] if '--no-scanner' in opts: scanner = False else: scanner = True qsrand(QTime(0, 0, 0).secsTo(QTime.currentTime())) locale = settings.get('ui:lang') if not locale: locale = QLocale.system().name() qtTranslator = QTranslator() if qtTranslator.load(":/translations/ts/lector_" + locale, 'ts'): app.installTranslator(qtTranslator) window = Window(scanner) window.show() app.exec_()