def storage(): datapath = os.path.dirname(__file__) + '\data' imgpath = r'D:\\IMG' gmp = GMP(imgpath) regisration = Regisration(imgpath) license = License(imgpath) certificate = ProductionCertificate(datapath, imgpath) pga = Improtdrug(imgpath) for file in os.walk(datapath): id_code = randomidcode() for file_name in file[2]: # if 'GMP证书' in file_name: gmp.gmp(file[0], id_code) # elif "营业执照" in file_name: license.license(file[0], id_code) # elif "药品再注册批件" in file_name: regisration.regisration(file[0], id_code) # elif '药品生产许可证' in file_name: certificate.recognize(file[0], id_code) # elif '说明书' in file_name: introduction.run_introduction(file[0], id_code) # elif '进口药品注册证' in file_name: try: pga.start(file[0], id_code, 'shuai', '') except Exception as e: logmgr = LogMgr() logmgr.error(file[0]+ ":" + str(e)) continue break
def fill(self, _id, useless=None): """ Заполняет поля лицензей, получая как параметр ее id Так же очищает лицензию, если useless == 0 Дополнительно меняет состояние программы и название кнопки """ if useless: self.unblock_forms() if self.state == self.NEW: reply = self.open_dialog("Вы не сохранили изменения, все равно выйти?", "Предупреждение") if not reply: return if _id is None: return if useless == 0: # трюк, чтобы не писать лишнего метода на очистку # параметр useless все равно передается от события license = License() elif _id.text() == 'Фильтр': license = self.filter self.action_button.setText('Поиск') self.delete_button.setEnabled(False) self.curr_id = None self.state = None else: license = License.get_by_id(_id.text()) self.action_button.setText('Сохранить') self.delete_button.setEnabled(True) self.curr_id = int(_id.text()) self.state = self.EDIT self.update_title() for field in License.fields: if not license[field.eng]: if field.type == date: self.input_forms[field.eng].setDate(self.MIN_DATE) #elif field. else: self.input_forms[field.eng].clear() continue if field.type == date: l_date = Frame.parse_date(license[field.eng]) in_date = QDate(l_date) self.input_forms[field.eng].setDate(in_date) elif field.type == str: self.input_forms[field.eng].setText(license[field.eng]) else: self.input_forms[field.eng].setText(str(license[field.eng]))
def act(self): """ Функция, реагирующя на нажатие кнопок "Сохранить" и "Найти" Меняет свое действие и название в зависимости от текущего состояния программы """ self.unblock_forms() if self.action_button.text() == 'Сохранить': license = self.parse_license() if not license: QMessageBox.question(self, "Ошибка", "Поле № Лицензии не может быть пустым", QMessageBox.Ok) return if self.state == self.NEW: if License.get_by_id(int(self.input_forms['id'].text())): QMessageBox.question(self, "Ошибка", "Лицензия с номером %s уже есть в базе\nСохранение невозможно" % (self.input_forms['id'].text()), QMessageBox.Ok) return license.write() self.curr_id = license['id'] self.state = self.EDIT self.update_list() else: attrs = self.parse_attributes() self.update_list(attrs) self.state = self.EDIT
def __init__(self, desktop): super().__init__() self.curr_id = None self.filter = License() self.input_forms = {} self.initGUI(desktop) self.setWindowTitle('Контроль лицензий') self.state = self.EDIT
def delete(self): """ Функция, реагирующая на нажатие кнопки "Удалить" """ reply = self.open_dialog("Вы собираетесь удалить лицензию №%d" % self.curr_id, "Удаление") if reply: license = License.get_by_id(self.curr_id) license.delete() self.clear_forms() self.update_list()
def update_list(self, attrs=None): """ Функция обновляет список лицензий 1. Когда применен фильтр по поиску 2. Когда удалилась лицензия 3. Когда добавилась новая лицензия """ self.list_view.clear() license_list = License.find(attrs) self.list_view.addItem('Фильтр') for license in license_list: self.list_view.addItem(str(license))
def storage(json_file): datapath = os.path.dirname(__file__) + '\data' imgpath = r'D:\\IMG' introduction = Inrtroduction(imgpath) gmp = GMP(imgpath) regisration = Regisration(imgpath) license = License(imgpath) certificate = ProductionCertificate(datapath, imgpath) pga = Improtdrug(imgpath) files = json_file['files'] for file in files: if '说明书' in file['type']: introduction_dict = introduction.introduction_deploy( file['imgs'], '12345') elif 'GMP' in file['type']: gmp_dict = gmp.gmp_delploy(file['imgs'], '12345') elif '注册批件' in file['type']: regisration_dict = regisration.regisration_deploy( file['imgs'], '12345') elif '营业执照' in file['type']: license_dict = license.license_deploy(file['imgs'], '12345') elif '许可证' in file['type']: certificate_dict = certificate.recognize_deploy( file['imgs'], '12345')
def parse_license(self): """ Парсит лицензию целиком, и если значения пустые, прописывает дефолтные """ curr_license = License() for field in License.fields: if field.type == date: curr_license[field.eng] = \ self.input_forms[field.eng].date().toPyDate() else: value = self.input_forms[field.eng].text() if field.type == int: if field.eng == 'id': if value == '': return else: curr_license[field.eng] = int(value) else: curr_license[field.eng] = int(value) if value else 0 else: curr_license[field.eng] = value return curr_license
def __init__(self, stdscreen, options_file): self.screen = stdscreen # Init the colors curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE) curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_WHITE) curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_GREEN) curses.init_pair(4, curses.COLOR_RED, curses.COLOR_WHITE) self.screen.bkgd(' ', curses.color_pair(1)) self.maxy, self.maxx = self.screen.getmaxyx() self.screen.addstr(self.maxy - 1, 0, ' Arrow keys make selections; <Enter> activates.') curses.curs_set(0) self.cd_path = None kernel_params = subprocess.check_output(['cat', '/proc/cmdline']) # check the kickstart param ks_config = None m = re.match(r".*ks=(\S+)\s*.*\s*", kernel_params) if m != None: ks_config = self.get_config(m.group(1)) # check for the repo param m = re.match(r".*repo=(\S+)\s*.*\s*", kernel_params) if m != None: rpm_path = m.group(1) else: # the rpms should be in the cd self.mount_RPMS_cd() rpm_path = os.path.join(self.cd_path, "RPMS") # This represents the installer screen, the bool indicated if I can go back to this window or not items = [] if not ks_config: random_id = '%12x' % random.randrange(16**12) random_hostname = "photon-" + random_id.strip() install_config = {'iso_system': False} license_agreement = License(self.maxy, self.maxx) select_disk = SelectDisk(self.maxy, self.maxx, install_config) select_partition = PartitionISO(self.maxy, self.maxx, install_config) package_selector = PackageSelector(self.maxy, self.maxx, install_config, options_file) self.alpha_chars = range(65, 91) self.alpha_chars.extend(range(97, 123)) partition_accepted_chars = list(range(48, 58)) hostname_accepted_chars = list(self.alpha_chars) # Adding the numeric chars hostname_accepted_chars.extend(range(48, 58)) # Adding the . and - hostname_accepted_chars.extend([ord('.'), ord('-')]) hostname_reader = WindowStringReader( self.maxy, self.maxx, 10, 70, 'hostname', None, # confirmation error msg if it's a confirmation text None, # echo char hostname_accepted_chars, # set of accepted chars self.validate_hostname, # validation function of the input None, # post processing of the input field 'Choose the hostname for your system', 'Hostname:', 2, install_config, random_hostname, True) root_password_reader = WindowStringReader( self.maxy, self.maxx, 10, 70, 'password', None, # confirmation error msg if it's a confirmation text '*', # echo char None, # set of accepted chars self.validate_password, # validation function of the input None, # post processing of the input field 'Set up root password', 'Root password:'******'password', "Passwords don't match, please try again.", # confirmation error msg if it's a confirmation text '*', # echo char None, # set of accepted chars None, # validation function of the input self. generate_password_hash, # post processing of the input field 'Confirm root password', 'Confirm Root password:'******'iso_system'] = False if self.is_vmware_virtualization( ) and 'install_linux_esx' not in install_config: install_config['install_linux_esx'] = True installer = InstallerContainer(install_config, self.maxy, self.maxx, True, rpm_path=rpm_path, log_path="/var/log", ks_config=ks_config) items = items + [(installer.install, False)] index = 0 params = None while True: result = items[index][0](params) if result.success: index += 1 params = result.result if index == len(items) - 1: self.screen.clear() if index == len(items): break #Skip linux select screen for ostree installation. if index == select_linux_index: if (install_config['type'] == 'ostree_server'): index += 1 else: index -= 1 while index >= 0 and items[index][1] == False: index -= 1 if index < 0: index = 0 #Skip linux select screen for ostree installation. if index == select_linux_index: if (install_config['type'] == 'ostree_server'): index -= 1
# # Main # # Define command line parser and get cli arguments. args = parseArguments() # Use default or user provided maximum sample numbers maxNrTargetSamplesPerLabel = int(args.restrictedNrSubjectSamples[0]) maxNrNonTargetSamplesPerLabel = int(args.restrictedNrSubjectSamples[1]) # Let's handle any request for the license first. # We stop the program after that. if args.showLicense: l = License('LICENSE.txt') l.showLicense() exit(0) # Name of the experiment, used as _title in plots. expName = args.expName # We do not like spaces! filenames = sanitize(args.filenames) # filename = args.filename dataType = args.dataType # Threshold used by biometric system to make a decision # only of interest if you want to plot the systems Accuracy. threshold = args.threshold
def ui_config(self, options_file, maxy, maxx): # This represents the installer screen, the bool indicated if I can go back to this window or not items = [] random_id = '%12x' % random.randrange(16**12) random_hostname = "photon-" + random_id.strip() install_config = {'iso_system': False} install_config['ui_install'] = True license_agreement = License(maxy, maxx) select_disk = SelectDisk(maxy, maxx, install_config) select_partition = PartitionISO(maxy, maxx, install_config) package_selector = PackageSelector(maxy, maxx, install_config, options_file) self.alpha_chars = list(range(65, 91)) self.alpha_chars.extend(range(97, 123)) hostname_accepted_chars = self.alpha_chars # Adding the numeric chars hostname_accepted_chars.extend(range(48, 58)) # Adding the . and - hostname_accepted_chars.extend([ord('.'), ord('-')]) hostname_reader = WindowStringReader( maxy, maxx, 10, 70, 'hostname', None, # confirmation error msg if it's a confirmation text None, # echo char hostname_accepted_chars, # set of accepted chars self.validate_hostname, # validation function of the input None, # post processing of the input field 'Choose the hostname for your system', 'Hostname:', 2, install_config, random_hostname, True) root_password_reader = WindowStringReader( maxy, maxx, 10, 70, 'password', None, # confirmation error msg if it's a confirmation text '*', # echo char None, # set of accepted chars IsoConfig.validate_password, # validation function of the input None, # post processing of the input field 'Set up root password', 'Root password:'******'password', "Passwords don't match, please try again.", # confirmation error msg if it's a confirmation text '*', # echo char None, # set of accepted chars None, # validation function of the input IsoConfig.generate_password_hash, # post processing of the input field 'Confirm root password', 'Confirm Root password:'******'type'] == 'ostree_server': index += 1 else: index -= 1 while index >= 0 and items[index][1] is False: index -= 1 if index < 0: index = 0 #Skip linux select screen for ostree installation. if index == select_linux_index: if install_config['type'] == 'ostree_server': index -= 1 return install_config
args = parser.parse_args() #========================== # Read config file #========================== file = args.config config = {} if file: file = '../../config/{0}'.format(file) with open(file) as infile: print infile for line in infile: (key, val) = line.split(' = ') config[str(key)] = val.strip('\n') else: LOGGER.error("No configuration file.") sys.exit(1) #========================== # License #========================== License = License(config) result = wf_license(LOGGER, License, config, args) if result == True: LOGGER.info("BIGIP Licence State = LICENSED. SUCCESS") else: LOGGER.info("BIGIP Licence State = FAILED.")
def __init__(self, stdscreen, argv): self.screen = stdscreen if len(argv) == 2: local_install = True else: local_install = False # Init the colors curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE) curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_WHITE) curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_GREEN) curses.init_pair(4, curses.COLOR_RED, curses.COLOR_WHITE) self.screen.bkgd(' ', curses.color_pair(1)) self.maxy, self.maxx = self.screen.getmaxyx() self.screen.addstr(self.maxy - 1, 0, '<Tab> moves; <Space> selects; <Enter> forward') curses.curs_set(0) self.install_config = {} license_agreement = License(self.maxy, self.maxx) # skip the disk selection and partitioning if we are running with conf file in test environment. if local_install == True: # Read the conf file self.install_config = (JsonWrapper(argv[1])).read() self.install_config['iso_system'] = False else: self.install_config['iso_system'] = False disk_partitioner = DiskPartitioner(self.maxy, self.maxx) select_disk = SelectDisk(self.maxy, self.maxx, self.install_config) package_selector = PackageSelector(self.maxy, self.maxx, self.install_config) custom_package_selector = CustomPackageSelector( self.maxy, self.maxx, self.install_config) hostname_reader = WindowStringReader( self.maxy, self.maxx, 10, 70, False, 'Choose the hostname for your system', 'Hostname:', 2, self.install_config) root_password_reader = WindowStringReader(self.maxy, self.maxx, 10, 70, True, 'Set up root password', 'Root password:', 2, self.install_config) installer = Installer(self.install_config, self.maxy, self.maxx, True, local_install, tools_path="/usr/src/photon", rpm_path="/usr/src/photon/RPMS", log_path="/var/log") # This represents the installer screen, the bool indicated if I can go back to this window or not items = [(package_selector.display, True), (custom_package_selector.display, False), (hostname_reader.get_user_string, True), (root_password_reader.get_user_string, True), (installer.install, False)] # Include disk selection and partitioning in state machine when there is no extra param. if local_install == False: items = [ #(disk_partitioner.display, True), (select_disk.display, True) ] + items items = [(license_agreement.display, False)] + items index = 0 params = None while True: result = items[index][0](params) if result.success: index += 1 params = result.result if index == len(items): break else: index -= 1 while index >= 0 and items[index][1] == False: index -= 1 if index < 0: index = 0
# MotivateU by Shankhanil, Chhanda from Quotes import Quotes, Quotes2 from license import License from SocialBot import SocialBot import sys import urllib.request class UnknownCommandException(Exception): pass if __name__ == "__main__": quote = Quotes2() tweetbot = SocialBot() license = License() try: urllib.request.urlopen('https://google.com') try: if sys.argv[1] == 'quote': print('Here\'s a random quote for you') Q = quote.formatQuote(quote.getQuote(quote.generateQuote())) print(Q) print("Like this quote? Want to tweet it? (Y/n)") choice = input() if choice == 'y' or choice == 'Y': tweetbot.login() if len(Q) > 140: print('''\ This quote is more than 140 characters long.\n\ This tweet will be truncated to 140 characters.\n\
import json from license import License company = "shfanxi" email = "*****@*****.**" full_name = "Jackson" hostname = "DESKTOP-E062GCK" start_date = "2019年4月20号" expiration_date = "2032年4月19号" nodes = 20 license_type = "Normal" lic = License().get_license(company, email, full_name, hostname, start_date, expiration_date, nodes, license_type) with open("LICENSE.txt", "w") as fp: json_str = json.dumps( lic, sort_keys=True, indent=4, separators=(',', ':')).encode('utf-8').decode('unicode_escape') print(json_str) fp.write( json.dumps(lic, sort_keys=True, indent=4, separators=(',', ':')).encode('utf-8').decode('unicode_escape'))
def add_ui_pages(self, options_file, maxy, maxx, install_config): items = [] license_agreement = License(maxy, maxx) select_disk = SelectDisk(maxy, maxx, install_config) select_partition = PartitionISO(maxy, maxx, install_config) package_selector = PackageSelector(maxy, maxx, install_config, options_file) hostname_reader = WindowStringReader( maxy, maxx, 10, 70, 'hostname', None, # confirmation error msg if it's a confirmation text None, # echo char self.hostname_accepted_chars, # set of accepted chars IsoConfig.validate_hostname, # validation function of the input None, # post processing of the input field 'Choose the hostname for your system', 'Hostname:', 2, install_config, self.random_hostname, True) root_password_reader = WindowStringReader( maxy, maxx, 10, 70, 'password', None, # confirmation error msg if it's a confirmation text '*', # echo char None, # set of accepted chars IsoConfig.validate_password, # validation function of the input None, # post processing of the input field 'Set up root password', 'Root password:'******'password', # confirmation error msg if it's a confirmation text "Passwords don't match, please try again.", '*', # echo char None, # set of accepted chars None, # validation function of the input IsoConfig. generate_password_hash, # post processing of the input field 'Confirm root password', 'Confirm Root password:', 2, install_config) items.append((license_agreement.display, False)) items.append((select_disk.display, True)) items.append((select_partition.display, False)) items.append((select_disk.guided_partitions, False)) items.append((package_selector.display, True)) select_linux_index = -1 if self.is_vmware_virtualization(): linux_selector = LinuxSelector(maxy, maxx, install_config) items.append((linux_selector.display, True)) select_linux_index = items.index((linux_selector.display, True)) items.append((hostname_reader.get_user_string, True)) items.append((root_password_reader.get_user_string, True)) items.append((confirm_password_reader.get_user_string, False)) return items, select_linux_index
def add_ui_pages(self, install_config, ui_config, maxy, maxx): items = [] license_agreement = License(maxy, maxx) select_disk = SelectDisk(maxy, maxx, install_config) custom_partition = CustomPartition(maxy, maxx, install_config) package_selector = PackageSelector(maxy, maxx, install_config, ui_config['options_file']) hostname_reader = WindowStringReader( maxy, maxx, 10, 70, 'hostname', None, # confirmation error msg if it's a confirmation text None, # echo char self.hostname_accepted_chars, # set of accepted chars IsoConfig.validate_hostname, # validation function of the input None, # post processing of the input field 'Choose the hostname for your system', 'Hostname:', 2, install_config, self.random_hostname, True) root_password_reader = WindowStringReader( maxy, maxx, 10, 70, 'shadow_password', None, # confirmation error msg if it's a confirmation text '*', # echo char None, # set of accepted chars IsoConfig.validate_password, # validation function of the input None, # post processing of the input field 'Set up root password', 'Root password:'******'shadow_password', # confirmation error msg if it's a confirmation text "Passwords don't match, please try again.", '*', # echo char None, # set of accepted chars None, # validation function of the input CommandUtils.generate_password_hash, # post processing of the input field 'Confirm root password', 'Confirm Root password:'******'repo_url', None, # confirmation error msg if it's a confirmation text None, # echo char None, # set of accepted chars IsoConfig.validate_ostree_url_input, # validation function of the input None, # post processing of the input field 'Please provide the URL of OSTree repo', 'OSTree Repo URL:', 2, install_config, "http://") ostree_ref_reader = OSTreeWindowStringReader( maxy, maxx, 10, 70, 'repo_ref', None, # confirmation error msg if it's a confirmation text None, # echo char None, # set of accepted chars IsoConfig.validate_ostree_refs_input, # validation function of the input None, # post processing of the input field 'Please provide the Refspec in OSTree repo', 'OSTree Repo Refspec:', 2, install_config, "photon/3.0/x86_64/minimal") confirm_window = ConfirmWindow(11, 60, maxy, maxx, (maxy - 11) // 2 + 7, 'Start installation? All data on the selected disk will be lost.\n\n' 'Press <Yes> to confirm, or <No> to quit') # This represents the installer screens, the bool indicated if # I can go back to this window or not items.append((license_agreement.display, False)) items.append((select_disk.display, True)) items.append((custom_partition.display, False)) items.append((package_selector.display, True)) if 'network_screen' in ui_config: allow_vlan = ui_config['network_screen'].get('allow_vlan', False) net_cfg = NetworkConfigure(maxy, maxx, install_config, allow_vlan) items.append((net_cfg.display, True)) if 'download_screen' in ui_config: title = ui_config['download_screen'].get('title', None) intro = ui_config['download_screen'].get('intro', None) dest = ui_config['download_screen'].get('destination', None) fd = FileDownloader(maxy, maxx, install_config, title, intro, dest, True) items.append((fd.display, True)) if CommandUtils.is_vmware_virtualization(): linux_selector = LinuxSelector(maxy, maxx, install_config) items.append((linux_selector.display, True)) items.append((hostname_reader.get_user_string, True)) items.append((root_password_reader.get_user_string, True)) items.append((confirm_password_reader.get_user_string, False)) items.append((ostree_server_selector.display, True)) items.append((ostree_url_reader.get_user_string, True)) items.append((ostree_ref_reader.get_user_string, True)) items.append((confirm_window.do_action, True)) return items
def add_ui_pages(self, options_file, maxy, maxx, install_config): items = [] license_agreement = License(maxy, maxx) select_disk = SelectDisk(maxy, maxx, install_config) select_partition = PartitionISO(maxy, maxx, install_config) package_selector = PackageSelector(maxy, maxx, install_config, options_file) hostname_reader = WindowStringReader( maxy, maxx, 10, 70, 'hostname', None, # confirmation error msg if it's a confirmation text None, # echo char self.hostname_accepted_chars, # set of accepted chars IsoConfig.validate_hostname, # validation function of the input None, # post processing of the input field 'Choose the hostname for your system', 'Hostname:', 2, install_config, self.random_hostname, True) root_password_reader = WindowStringReader( maxy, maxx, 10, 70, 'password', None, # confirmation error msg if it's a confirmation text '*', # echo char None, # set of accepted chars IsoConfig.validate_password, # validation function of the input None, # post processing of the input field 'Set up root password', 'Root password:'******'password', # confirmation error msg if it's a confirmation text "Passwords don't match, please try again.", '*', # echo char None, # set of accepted chars None, # validation function of the input IsoConfig. generate_password_hash, # post processing of the input field 'Confirm root password', 'Confirm Root password:'******'ostree_repo_url', None, # confirmation error msg if it's a confirmation text None, # echo char None, # set of accepted chars IsoConfig. validate_ostree_url_input, # validation function of the input None, # post processing of the input field 'Please provide the URL of OSTree repo', 'OSTree Repo URL:', 2, install_config, "http://") ostree_ref_reader = OSTreeWindowStringReader( maxy, maxx, 10, 70, 'ostree_repo_ref', None, # confirmation error msg if it's a confirmation text None, # echo char None, # set of accepted chars IsoConfig. validate_ostree_refs_input, # validation function of the input None, # post processing of the input field 'Please provide the Refspec in OSTree repo', 'OSTree Repo Refspec:', 2, install_config, "photon/3.0/x86_64/minimal") confirm_window = ConfirmWindow( 11, 60, maxy, maxx, (maxy - 11) // 2 + 7, 'Start installation? All data on the selected disk will be lost.\n\n' 'Press <Yes> to confirm, or <No> to quit') items.append((license_agreement.display, False)) items.append((select_disk.display, True)) items.append((select_partition.display, False)) items.append((package_selector.display, True)) if self.is_vmware_virtualization(): linux_selector = LinuxSelector(maxy, maxx, install_config) items.append((linux_selector.display, True)) items.append((hostname_reader.get_user_string, True)) items.append((root_password_reader.get_user_string, True)) items.append((confirm_password_reader.get_user_string, False)) items.append((ostree_server_selector.display, True)) items.append((ostree_url_reader.get_user_string, True)) items.append((ostree_ref_reader.get_user_string, True)) items.append((confirm_window.do_action, True)) return items
def initUI(self): self.driver_widget = Driver() self.device_widget = Device(self.driver_widget) self.about_widget = About() self.settings_widget = Settings() self.leakTest_widget = LeakTest() self.diagram_widget = Diagram() self.license_widget = License() self.dwt_widget = DWT(self.driver_widget) self.centralWidget = QMdiArea(self) self.setCentralWidget(self.centralWidget) self.sub1 = QMdiSubWindow() self.sub1.setWidget(self.driver_widget) self.centralWidget.addSubWindow(self.sub1) self.sub1.show() self.sub2 = QMdiSubWindow() self.sub2.setWidget(self.device_widget) self.centralWidget.addSubWindow(self.sub2) self.sub2.show() self.setWindowTitle("menu demo") self.showMaximized() self.setWindowTitle(self.title) self.setGeometry(0, 0, self.width, self.height) qtRectangle = self.frameGeometry() centerPoint = QDesktopWidget().availableGeometry().center() qtRectangle.moveCenter(centerPoint) self.move(qtRectangle.topLeft()) mainMenu = self.menuBar() mainMenu.setNativeMenuBar(False) fileMenu = mainMenu.addMenu('File') viewMenu = mainMenu.addMenu('View') helpMenu = mainMenu.addMenu('Help') saveButton = QAction('Save last configuration ...', self) saveButton.setShortcut('Ctrl+S') saveButton.triggered.connect(self.connectDevice) fileMenu.addAction(saveButton) loadButton = QAction('Load last configuration ...', self) loadButton.setShortcut('Ctrl+L') loadButton.triggered.connect(self.connectDevice) fileMenu.addAction(loadButton) connectButton = QAction('Connect to ...', self) connectButton.setShortcut('Ctrl+C') #connectButton.setStatusTip('Connect device') connectButton.triggered.connect(self.connectDevice) fileMenu.addAction(connectButton) disconnectButton = QAction('Disconnect all', self) disconnectButton.setShortcut('Ctrl+D') #connectButton.setStatusTip('Connect device') disconnectButton.triggered.connect(self.disconnectAll) fileMenu.addAction(disconnectButton) fileMenu.addSeparator() exitButton = QAction('Exit', self) exitButton.setShortcut('Ctrl+Q') exitButton.setStatusTip('Exit application') exitButton.triggered.connect(self.close) fileMenu.addAction(exitButton) diagramButton = QAction('Show diagram', self) diagramButton.triggered.connect(self.openDiagram) viewMenu.addAction(diagramButton) leakTestButton = QAction('Leak test...', self) leakTestButton.triggered.connect(self.openLeakTest) viewMenu.addAction(leakTestButton) settingsButton = QAction('Settings', self) settingsButton.triggered.connect(self.openSettings) viewMenu.addAction(settingsButton) dwtButton = QAction('DWT', self) dwtButton.triggered.connect(self.openDWT) viewMenu.addAction(dwtButton) """ helpButton = QAction(QIcon('icon.png'), 'Help', self) helpButton.setShortcut('Ctrl+H') helpButton.setStatusTip('Help') helpButton.triggered.connect(self.close) helpMenu.addAction(helpButton) """ aboutButton = QAction(QIcon('icon.png'), 'About program', self) aboutButton.setShortcut('Ctrl+A') aboutButton.setStatusTip('About program') aboutButton.triggered.connect(self.openAbout) helpMenu.addAction(aboutButton) licenseButton = QAction(QIcon('icon.png'), 'Licence info', self) licenseButton.setShortcut('Ctrol+L') licenseButton.setStatusTip('License inforamation') licenseButton.triggered.connect(self.openLicense) helpMenu.addAction(licenseButton) self.statusBar().showMessage('DPI620 connected; PACE1000 connected') """ wid = QWidget(self) self.setCentralWidget(wid) grid = QGridLayout() grid.setSpacing(10) wid.setLayout(grid) title = QLabel('Title') author = QLabel('Author') review = QLabel('Review') titleEdit = QLineEdit() authorEdit = QLineEdit() reviewEdit = QTextEdit() clearButton = QPushButton('Send', self) grid.addWidget(title, 1, 0) grid.addWidget(titleEdit, 1, 1) grid.addWidget(author, 2, 0) grid.addWidget(authorEdit, 2, 1) grid.addWidget(review, 3, 0) grid.addWidget(reviewEdit, 3, 1, 5, 1) grid.addWidget(clearButton, 9, 1) """ # button.move(self.frameGeometry().width()-110, self.frameGeometry().height()-50) self.setGeometry(0, 0, 800, 600) qtRectangle = self.frameGeometry() centerPoint = QDesktopWidget().availableGeometry().center() qtRectangle.moveCenter(centerPoint) self.move(qtRectangle.topLeft()) self.setWindowTitle('Calibri') #self.setWindowIcon(QIcon('plus.gif')) self.show()
%s comes with ABSOLUTELY NO WARRANTY; for details run \'%s -h\'.\ This is free software, and you are welcome to redistribute it\ under certain conditions; run \'%s -l\' for details.\ This program was written by Jos Bouten.\ You can contact me via josbouten at gmail dot com." % (progName, version, progName, progName, progName)) parser.add_argument('-i', '--input', action="store", dest="inputfile", help="input file name") parser.add_argument('-o', '--output', action="store", dest="outputfile", help="output file name") parser.add_argument('-l', '--license', action="store_true", dest="showLicense", help="show license") return parser.parse_args() if __name__ == '__main__': # Define command line parser and get cli arguments. args = parseArguments() # Let's handle any request for the license first. # We stop the program after that. debug = False if args.showLicense: l = License('LICENSE.txt', debug) l.showLicense() exit(0) if args.inputfile: metaValue = 'META' vData = VocaliseData(args.inputfile, metaValue, debug) if args.outputfile: # Print converted data to file vData.convert2bioplot(args.outputfile) else: # Print to standard output device. vData.convert2bioplot('stdout')
def __init__(self, stdscreen, options_file): self.screen = stdscreen # Init the colors curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE) curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_WHITE) curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_GREEN) curses.init_pair(4, curses.COLOR_RED, curses.COLOR_WHITE) self.screen.bkgd(' ', curses.color_pair(1)) self.maxy, self.maxx = self.screen.getmaxyx() self.screen.addstr(self.maxy - 1, 0, '<Tab> moves; <Space> selects; <Enter> forward') curses.curs_set(0) self.cd_path = None kernel_params = subprocess.check_output(['cat', '/proc/cmdline']) # check the kickstart param ks_config = None m = re.match(r".*ks=(\S+)\s*.*\s*", kernel_params) if m != None: ks_config = self.get_config(m.group(1)) # check for the repo param m = re.match(r".*repo=(\S+)\s*.*\s*", kernel_params) if m != None: rpm_path = m.group(1) else: # the rpms should be in the cd self.mount_RPMS_cd() rpm_path = os.path.join(self.cd_path, "RPMS") # This represents the installer screen, the bool indicated if I can go back to this window or not items = [] if not ks_config: random_id = '%12x' % random.randrange(16**12) random_hostname = "photon-" + random_id.strip() install_config = {'iso_system': False} license_agreement = License(self.maxy, self.maxx) select_disk = SelectDisk(self.maxy, self.maxx, install_config) package_selector = PackageSelector(self.maxy, self.maxx, install_config, options_file) self.alpha_chars = range(65, 91) self.alpha_chars.extend(range(97, 123)) hostname_accepted_chars = list(self.alpha_chars) # Adding the numeric chars hostname_accepted_chars.extend(range(48, 58)) # Adding the . and - hostname_accepted_chars.extend([ord('.'), ord('-')]) hostname_reader = WindowStringReader( self.maxy, self.maxx, 10, 70, 'hostname', None, # confirmation error msg if it's a confirmation text None, # echo char hostname_accepted_chars, # set of accepted chars self.validate_hostname, # validation function of the input None, # post processing of the input field 'Choose the hostname for your system', 'Hostname:', 2, install_config, random_hostname) root_password_reader = WindowStringReader( self.maxy, self.maxx, 10, 70, 'password', None, # confirmation error msg if it's a confirmation text '*', # echo char None, # set of accepted chars self.validate_password, # validation function of the input None, # post processing of the input field 'Set up root password', 'Root password:'******'password', "Passwords don't match, please try again.", # confirmation error msg if it's a confirmation text '*', # echo char None, # set of accepted chars None, # validation function of the input self. generate_password_hash, # post processing of the input field 'Confirm root password', 'Confirm Root password:'******'ostree_repo_url', None, # confirmation error msg if it's a confirmation text None, # echo char None, # set of accepted chars self. validate_ostree_url_input, # validation function of the input None, # post processing of the input field 'Please provide the URL of OSTree repo', 'OSTree Repo URL:', 2, install_config, "http://") ostree_ref_reader = OSTreeWindowStringReader( self.maxy, self.maxx, 10, 70, 'ostree_repo_ref', None, # confirmation error msg if it's a confirmation text None, # echo char None, # set of accepted chars self. validate_ostree_refs_input, # validation function of the input None, # post processing of the input field 'Please provide the Ref in OSTree repo', 'OSTree Repo Ref:', 2, install_config, "photon/tp2/x86_64/minimal") items = items + [ (license_agreement.display, False), (select_disk.display, True), (package_selector.display, True), (hostname_reader.get_user_string, True), (root_password_reader.get_user_string, True), (confirm_password_reader.get_user_string, False), (ostree_server_selector.display, True), (ostree_url_reader.get_user_string, True), (ostree_ref_reader.get_user_string, True), ] else: install_config = ks_config install_config['iso_system'] = False installer = InstallerContainer(install_config, self.maxy, self.maxx, True, rpm_path=rpm_path, log_path="/var/log", ks_config=ks_config) items = items + [(installer.install, False)] index = 0 params = None while True: result = items[index][0](params) if result.success: index += 1 params = result.result if index == len(items): break else: index -= 1 while index >= 0 and items[index][1] == False: index -= 1 if index < 0: index = 0
def __init__(self, stdscreen): self.screen = stdscreen # Init the colors curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE) curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_WHITE) curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_GREEN) curses.init_pair(4, curses.COLOR_RED, curses.COLOR_WHITE) self.screen.bkgd(' ', curses.color_pair(1)) self.maxy, self.maxx = self.screen.getmaxyx() self.screen.addstr(self.maxy - 1, 0, '<Tab> moves; <Space> selects; <Enter> forward') curses.curs_set(0) self.install_config = {'iso_system': False} # Mount the cd for the RPM, tools, and may be the ks cd_path = self.mount_RPMS_cd() # check the kickstart params ks_config = None kernel_params = subprocess.check_output(['cat', '/proc/cmdline']) m = re.match(r".*ks=(\S+)\s*.*\s*", kernel_params) if m != None: ks_config = self.get_config(m.group(1), cd_path) license_agreement = License(self.maxy, self.maxx) select_disk = SelectDisk(self.maxy, self.maxx, self.install_config) package_selector = PackageSelector(self.maxy, self.maxx, self.install_config) custom_package_selector = CustomPackageSelector( self.maxy, self.maxx, self.install_config) hostname_reader = WindowStringReader( self.maxy, self.maxx, 10, 70, False, 'Choose the hostname for your system', 'Hostname:', 2, self.install_config) root_password_reader = WindowStringReader(self.maxy, self.maxx, 10, 70, True, 'Set up root password', 'Root password:', 2, self.install_config) installer = Installer(self.install_config, self.maxy, self.maxx, True, tools_path=cd_path, rpm_path=os.path.join(cd_path, "RPMS"), log_path="/var/log", ks_config=ks_config) # This represents the installer screen, the bool indicated if I can go back to this window or not items = [] if not ks_config: items = items + [ (license_agreement.display, False), (select_disk.display, True), (package_selector.display, True), (custom_package_selector.display, False), (hostname_reader.get_user_string, True), (root_password_reader.get_user_string, True), ] items = items + [(installer.install, False)] index = 0 params = None while True: result = items[index][0](params) if result.success: index += 1 params = result.result if index == len(items): break else: index -= 1 while index >= 0 and items[index][1] == False: index -= 1 if index < 0: index = 0
dest="outputfile", help="output file name") parser.add_argument('-l', '--license', action="store_true", dest="showLicense", help="show license") return parser.parse_args() if __name__ == '__main__': # Define command line parser and get cli arguments. args = parseArguments() # Let's handle any request for the license first. # We stop the program after that. debug = False if args.showLicense: l = License('LICENSE.txt', debug) l.showLicense() exit(0) if args.inputfile: metaValue = 'META' vData = VocaliseData(args.inputfile, metaValue, debug) if args.outputfile: # Print converted data to file vData.convert2bioplot(args.outputfile) else: # Print to standard output device. vData.convert2bioplot('stdout')
# Initialize. sane.init() def get_devices(): # Try to find the devices. try: return sane.get_devices() except _sane.error: print('no devices found') finally: sane.exit() if __name__ == '__main__': print(License('pgscan', 'Jeremy A Gray', '*****@*****.**')) sane.init() devices = get_devices() scanner = sane.open(devices[0][0]) # options = scanner.get_options() # for option in options: # print(option) print(scanner.get_parameters()) print(scanner['mode']) scanner.mode = 'Color' print(scanner['mode']) print(scanner['resolution'])