def main_menu():
    while True:
        selection = input("\r\nEnter a selection:" "\r\n1 = check configuration" "\r\n2 = configure port"
                          "\r\n3 = enable port" "\r\n4 = add port description"
                          "\r\n5 = search by MAC address" "\r\n6 = attempt to resolve MAC to IP address"
                          '\r\n7 = exit'
                          "\r\nInput a choice here: ")
        if selection == "1":
            checking = check.Check()
            checking.check_config()
        elif selection == "2":
            config_port = config.Config()
            config_port.port_config()
        elif selection == "3":
            enable_port = config.Config()
            enable_port.port_enable()
        elif selection == '4':
            descr_port = config.Config()
            descr_port.port_description()
        elif selection == '5':
            macsearch.mac_search()
        elif selection == "6":
            resolve = check.Check()
            resolve.get_ip_mac_address()
        elif selection == '7':
            sys.exit()
        else:
            print("\r\nChoose either 1, 2, 3, 4, 5, 6, or 7" + "\r\n")
示例#2
0
    def load_pages(self):
        # misc.set_cursor(Gdk.CursorType.WATCH)
        self.pages["location"] = location.Location(self.params)
        self.pages["check"] = check.Check(self.params)
        self.pages["keymap"] = keymap.Keymap(self.params)
        self.pages["timezone"] = timezone.Timezone(self.params)
        self.pages["installation_ask"] = installation_ask.InstallationAsk(self.params)
        self.pages["installation_automatic"] = installation_automatic.InstallationAutomatic(self.params)

        if self.settings.get("enable_alongside"):
            self.pages["installation_alongside"] = installation_alongside.InstallationAlongside(self.params)
        else:
            self.pages["installation_alongside"] = None

        self.pages["installation_advanced"] = installation_advanced.InstallationAdvanced(self.params)
        self.pages["user_info"] = user_info.UserInfo(self.params)
        self.pages["slides"] = slides.Slides(self.params)
        # misc.set_cursor(Gdk.CursorType.ARROW)

        diff = 2

        num_pages = len(self.pages) - diff

        if num_pages > 0:
            self.progressbar_step = 1.0 / num_pages
示例#3
0
def test():
    ca1 = Checking(100, 'Alice')
    ca1.deposit(1000)
    ca2 = Checking(101, 'Bob')
    c1 = check.Check(ca1, ca2, 100)
    ca2.depositCheck(c1)
    print('Alice balance is', ca1.getBalance())
    print('Bob balance is', ca2.getBalance())
示例#4
0
def get_screen(screen_name, params):
    screen = None
    if screen_name == "DesktopAsk":
        import desktop
        screen = desktop.DesktopAsk(params)
    elif screen_name == "Check":
        import check
        screen = check.Check(params)
    elif screen_name == "Timezone":
        import timezone
        screen = timezone.Timezone(params)
        params['settings'].set('timezone_start', True)
    elif screen_name == "Wireless":
        import wireless
        screen = wireless.Wireless(params)
    elif screen_name == "Welcome":
        import welcome
        screen = welcome.Welcome(params)
    elif screen_name == "UserInfo":
        import user_info
        screen = user_info.UserInfo(params)
    elif screen_name == "Location":
        import location
        screen = location.Location(params)
    elif screen_name == "Language":
        import language
        screen = language.Language(params)
    elif screen_name == "Keymap":
        import keymap
        screen = keymap.Keymap(params)
    elif screen_name == "Features":
        import features
        screen = features.Features(params)
    elif screen_name == "Summary":
        import summary
        screen = summary.Summary(params)
    elif screen_name == "Slides":
        import slides
        screen = slides.Slides(params)
    elif screen_name == "InstallationAsk":
        import ask
        screen = ask.InstallationAsk(params)
    elif screen_name == "InstallationAdvanced":
        import advanced
        screen = advanced.InstallationAdvanced(params)
    elif screen_name == "InstallationAlongside":
        import alongside
        screen = alongside.InstallationAlongside(params)
    elif screen_name == "InstallationAutomatic":
        import automatic
        screen = automatic.InstallationAutomatic(params)
    elif screen_name == "zfs":
        import zfs
        screen = zfs.InstallationZFS(params)
    return screen
示例#5
0
文件: bank.py 项目: huj10001/cse1010
def test():
    import check
    b1 = Bank()
    ca1num = b1.createCheckingAccount('Alice')
    ca2num = b1.createCheckingAccount('Bob')
    b1.deposit(ca1num, 1000)
    check1 = check.Check(ca1num, 'Bob', 100)
    b1.depositCheck(ca2num, check1)
    print(b1.getAccountName(ca1num), 'balance is',
          b1.getAccountBalance(ca1num))
    print(b1.getAccountName(ca2num), 'balance is',
          b1.getAccountBalance(ca2num))
示例#6
0
    def load_pages(self):
        if not os.path.exists('/home/reborn/.config/openbox'):
            self.pages["language"] = language.Language(self.params)

        self.pages["check"] = check.Check(self.params)
        self.pages["location"] = location.Location(self.params)

        self.pages["mirrors"] = mirrors.Mirrors(self.params)

        self.pages["timezone"] = timezone.Timezone(self.params)

        if self.settings.get('desktop_ask'):
            self.pages["keymap"] = keymap.Keymap(self.params)
            self.pages["desktop"] = desktop.DesktopAsk(self.params)
            self.pages["features"] = features.Features(self.params)
        else:
            self.pages["keymap"] = keymap.Keymap(self.params,
                                                 next_page='features')
            self.pages["features"] = features.Features(self.params,
                                                       prev_page='keymap')

        self.pages["installation_ask"] = installation_ask.InstallationAsk(
            self.params)
        self.pages[
            "installation_automatic"] = installation_automatic.InstallationAutomatic(
                self.params)

        if self.settings.get("enable_alongside"):
            self.pages[
                "installation_alongside"] = installation_alongside.InstallationAlongside(
                    self.params)
        else:
            self.pages["installation_alongside"] = None

        self.pages[
            "installation_advanced"] = installation_advanced.InstallationAdvanced(
                self.params)
        self.pages["installation_zfs"] = installation_zfs.InstallationZFS(
            self.params)
        self.pages["summary"] = summary.Summary(self.params)
        self.pages["user_info"] = user_info.UserInfo(self.params)
        self.pages["slides"] = slides.Slides(self.params)

        diff = 2
        if os.path.exists('/home/antergos/.config/openbox'):
            # In minimal (openbox) we don't have a welcome screen
            diff = 3

        num_pages = len(self.pages) - diff

        if num_pages > 0:
            self.progressbar_step = 1.0 / num_pages
示例#7
0
    def __init__(self):
        # print('it works')
        checkStr = check.Check(test=True).getFiscalString()

        interface.UserInterface()

        # PNG TRYING
        # with open("./output/QR.png", "wb") as outputFile:
        #     qr = QR.create(checkStr)
        #     qr.png(outputFile, scale=4)

        # SVG TRYING
        with open("./output/QR.svg", "wb") as outputFile:
            qr = QR.QRCode(checkStr)
            qr.svg(file=outputFile, scale=4)
示例#8
0
文件: app.py 项目: 0x202036/word_api
def api_main():
    try:
        my_json =request.get_json()
        obj_receive = receive.Receive(my_json)
        if obj_receive.stage==3:
            angle11 = (obj_receive.word, '', [], 1)
            angle_send11 = send.Send(3, word=angle11[0], trans=angle11[1], sentence_list=angle11[2], length=angle11[3])
            angle_zhazha11 = dict(angle_send11)
            angle_j11 = json.dumps(obj=angle_zhazha11)
            return angle_j11

        obj_check = check.Check(receive=obj_receive)
        print(4)
        result = obj_check.begin_check()
        angle = (obj_receive.word, '', [['', '', '', '']], 1)
        if result != "safe":
            '''应为result !="safe:
            return jsonify(result)方便测试其他数据'''
            angle_send = send.Send( 2,angle[0],angle[1],angle[2],angle[3])
            angle_zhazha = dict(angle_send)
            angle_j = json.dumps(obj=angle_zhazha)
            return angle_j
        else:
            obj_db_manager = db_manager.Db_Manager(receive=obj_receive)
            obj_get_word_data = obj_db_manager.get_send_data()
            if obj_get_word_data == "NULL":
                Null_angle_send = send.Send(1, angle[0], angle[1], angle[2], angle[3])
                Null_angle_zhazha = dict(Null_angle_send)
                Null_angle_j = json.dumps(obj=Null_angle_zhazha)
                #该单词未录入
                return Null_angle_j
            obj_send = send.Send( 0,obj_get_word_data[0],obj_get_word_data[1],obj_get_word_data[2],obj_get_word_data[3])
            zhazha=dict(obj_send)
            j = json.dumps(obj=zhazha)
            return j

    except Exception as e:
        angle12 =("", '', [], 1)
        angle_send = send.Send( 3,angle12[0],angle12[1],angle12[2],angle12[3])
        angle_zhazha = dict(angle_send)
        angle_j = json.dumps(obj=angle_zhazha)
        print("异常")
        return angle_j
示例#9
0
    def __init__(self, app, cmd_line):
        Gtk.Window.__init__(self, title="Cnchi", application=app)

        # Check if we have administrative privileges
        if os.getuid() != 0:
            show.error(
                _('This installer must be run with administrative'
                  ' privileges, and cannot continue without them.'))
            sys.exit(1)

        # Check if we're already running
        tmp_running = "/tmp/.setup-running"
        if os.path.exists(tmp_running):
            show.error(
                _('You cannot run two instances of this installer.\n\n'
                  'If you are sure that the installer is not already running\n'
                  'you can manually delete the file %s\n'
                  'and run this installer again.') % tmp_running)
            sys.exit(1)

        logging.info(_("Cnchi installer version %s"), info.CNCHI_VERSION)

        self.settings = config.Settings()
        self.ui_dir = self.settings.get('ui')

        if not os.path.exists(self.ui_dir):
            cnchi_dir = os.path.join(os.path.dirname(__file__), './')
            self.settings.set('cnchi', cnchi_dir)

            ui_dir = os.path.join(os.path.dirname(__file__), 'ui/')
            self.settings.set('ui', ui_dir)

            data_dir = os.path.join(os.path.dirname(__file__), 'data/')
            self.settings.set('data', data_dir)

            self.ui_dir = self.settings.get('ui')

        if cmd_line.cache:
            self.settings.set('cache', cmd_line.cache)

        if cmd_line.copycache:
            self.settings.set('cache', cmd_line.copycache)
            self.settings.set('copy_cache', True)

        # For things we are not ready for users to test
        self.settings.set('z_hidden', cmd_line.z_hidden)

        # Set enabled desktops
        if self.settings.get('z_hidden'):
            self.settings.set("desktops", desktops.DESKTOPS_DEV)
        else:
            self.settings.set("desktops", desktops.DESKTOPS)

        self.ui = Gtk.Builder()
        self.ui.add_from_file(self.ui_dir + "cnchi.ui")

        self.add(self.ui.get_object("main"))

        self.header_ui = Gtk.Builder()
        self.header_ui.add_from_file(self.ui_dir + "header.ui")
        self.header = self.header_ui.get_object("header")

        self.logo = self.header_ui.get_object("logo")
        data_dir = self.settings.get('data')
        logo_path = os.path.join(data_dir, "images", "antergos",
                                 "antergos-logo-mini2.png")
        self.logo.set_from_file(logo_path)

        # To honor our css
        self.header.set_name("header")
        self.logo.set_name("logo")

        self.main_box = self.ui.get_object("main_box")
        self.progressbar = self.ui.get_object("main_progressbar")
        self.progressbar.set_name('process_progressbar')

        self.forward_button = self.header_ui.get_object("forward_button")
        self.backwards_button = self.header_ui.get_object("backwards_button")

        image1 = Gtk.Image()
        image1.set_from_icon_name("go-next", Gtk.IconSize.BUTTON)
        self.forward_button.set_label("")
        self.forward_button.set_image(image1)

        image2 = Gtk.Image()
        image2.set_from_icon_name("go-previous", Gtk.IconSize.BUTTON)
        self.backwards_button.set_label("")
        self.backwards_button.set_image(image2)

        # Create a queue. Will be used to report pacman messages (pacman/pac.py)
        # to the main thread (installation/process.py)
        self.callback_queue = multiprocessing.JoinableQueue()

        # Save in config if we have to use aria2 to download pacman packages
        self.settings.set("use_aria2", cmd_line.aria2)
        if cmd_line.aria2:
            logging.info(_("Using Aria2 to download packages - EXPERIMENTAL"))

        self.set_titlebar(self.header)

        # Load all pages
        # (each one is a screen, a step in the install process)

        params = dict()
        params['header'] = self.header
        params['ui_dir'] = self.ui_dir
        params['forward_button'] = self.forward_button
        params['backwards_button'] = self.backwards_button
        params['callback_queue'] = self.callback_queue
        params['settings'] = self.settings
        params['main_progressbar'] = self.progressbar

        if cmd_line.packagelist:
            params['alternate_package_list'] = cmd_line.packagelist
            logging.info(_("Using '%s' file as package list"),
                         params['alternate_package_list'])
        else:
            params['alternate_package_list'] = ""

        params['disable_tryit'] = cmd_line.disable_tryit
        params['testing'] = cmd_line.testing

        self.pages = dict()
        self.pages["welcome"] = welcome.Welcome(params)
        self.pages["language"] = language.Language(params)
        self.pages["location"] = location.Location(params)
        self.pages["check"] = check.Check(params)
        self.pages["desktop"] = desktop.DesktopAsk(params)
        self.pages["features"] = features.Features(params)
        self.pages["keymap"] = keymap.Keymap(params)
        self.pages["timezone"] = timezone.Timezone(params)
        self.pages["installation_ask"] = installation_ask.InstallationAsk(
            params)
        self.pages[
            "installation_automatic"] = installation_automatic.InstallationAutomatic(
                params)
        self.pages[
            "installation_alongside"] = installation_alongside.InstallationAlongside(
                params)
        self.pages[
            "installation_advanced"] = installation_advanced.InstallationAdvanced(
                params)
        self.pages["user_info"] = user_info.UserInfo(params)
        self.pages["slides"] = slides.Slides(params)

        self.connect('delete-event', self.on_exit_button_clicked)

        self.ui.connect_signals(self)
        self.header_ui.connect_signals(self)

        title = "Cnchi %s" % info.CNCHI_VERSION
        self.set_title(title)
        self.header.set_title(title)
        self.header.set_subtitle(_("Antergos Installer"))
        self.header.set_show_close_button(True)

        self.set_geometry()

        # Set window icon
        icon_path = os.path.join(data_dir, "images", "antergos",
                                 "antergos-icon.png")
        self.set_icon_from_file(icon_path)

        # Set the first page to show
        self.current_page = self.pages["welcome"]

        self.main_box.add(self.current_page)

        # Header style testing

        style_provider = Gtk.CssProvider()

        style_css = os.path.join(data_dir, "css", "gtk-style.css")

        with open(style_css, 'rb') as css:
            css_data = css.read()

        style_provider.load_from_data(css_data)

        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(), style_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

        # Show main window
        self.show_all()

        self.current_page.prepare('forwards')

        # Hide backwards button
        self.backwards_button.hide()

        # Hide titlebar but show border decoration
        #self.get_window().set_accept_focus(True)
        #self.get_window().set_decorations(Gdk.WMDecoration.BORDER)

        # Hide progress bar as it's value is zero
        self.progressbar.set_fraction(0)
        self.progressbar.hide()
        self.progressbar_step = 1.0 / (len(self.pages) - 2)

        with open(tmp_running, "w") as tmp_file:
            tmp_file.write("Cnchi %d\n" % 1234)
示例#10
0
 def writeCheck(self, to, amount):
     sourceAccount = self
     chk = check.Check(self, to, amount)
     return chk
示例#11
0
文件: thus.py 项目: g97iulio1609/thus
    def __init__(self):
        ## This allows to translate all py texts (not the glade ones)
        #gettext.textdomain(APP_NAME)
        #gettext.bindtextdomain(APP_NAME, LOCALE_DIR)
        #
        #locale_code, encoding = locale.getdefaultlocale()
        #lang = gettext.translation(APP_NAME, LOCALE_DIR, [locale_code], None, True)
        #lang.install()
        #
        ## With this we can use _("string") to translate
        #gettext.install(APP_NAME, localedir=LOCALE_DIR, codeset=None, names=[locale_code])

        # Check if we have administrative privileges
        if os.getuid() != 0:
            show.fatal_error(
                _('This installer must be run with administrative'
                  ' privileges and cannot continue without them.'))

        setup_logging()

        # Check if we're already running
        tmp_running = "/tmp/.setup-running"
        if os.path.exists(tmp_running):
            show.error(
                _('You cannot run two instances of this installer.\n\n'
                  'If you are sure that another installer is not already running\n'
                  'you can manually delete the file %s\n'
                  'and run this installer again.') % tmp_running)
            sys.exit(1)

        super().__init__()

        # workaround for dconf
        os.system("mkdir -p /root/.cache/dconf")
        os.system("chmod -R 777 /root/.cache")

        logging.info(_("Thus installer version %s"), info.THUS_VERSION)

        current_process = multiprocessing.current_process()
        logging.debug("[%d] %s started", current_process.pid,
                      current_process.name)

        self.settings = config.Settings()

        thus_dir = os.path.join(os.path.dirname(__file__), './')
        if os.path.exists(thus_dir):
            self.settings.set('thus', thus_dir)
        else:
            thus_dir = self.settings.get('thus')

        ui_dir = os.path.join(os.path.dirname(__file__), 'ui/')
        if os.path.exists(ui_dir):
            self.settings.set('ui', ui_dir)
        else:
            ui_dir = self.settings.get('ui')

        data_dir = os.path.join(os.path.dirname(__file__), 'data/')
        if os.path.exists(data_dir):
            self.settings.set('data', data_dir)
        else:
            data_dir = self.settings.get('data')

        if os.path.exists("/sys/firmware/efi"):
            self.settings.set('efi', True)

        self.ui = Gtk.Builder()
        self.ui.add_from_file(ui_dir + "thus.ui")

        self.add(self.ui.get_object("main"))

        self.header = self.ui.get_object("header")

        self.forward_button = self.ui.get_object("forward_button")

        self.logo = self.ui.get_object("logo")

        logo_dir = os.path.join(data_dir, "manjaro-logo-mini.png")

        self.logo.set_from_file(logo_dir)

        self.title = self.ui.get_object("title")

        # To honor our css
        self.title.set_name("header")
        self.logo.set_name("header")

        self.main_box = self.ui.get_object("main_box")
        self.progressbar = self.ui.get_object("progressbar1")

        self.forward_button = self.ui.get_object("forward_button")
        self.exit_button = self.ui.get_object("exit_button")
        self.backwards_button = self.ui.get_object("backwards_button")

        # Create a queue. Will be used to report pacman messages (pac.py)
        # to the main thread (installer_*.py)
        self.callback_queue = multiprocessing.JoinableQueue()

        # Load all pages
        # (each one is a screen, a step in the install process)

        self.pages = dict()

        params = dict()
        params['title'] = self.title
        params['forward_button'] = self.forward_button
        params['backwards_button'] = self.backwards_button
        params['exit_button'] = self.exit_button
        params['callback_queue'] = self.callback_queue
        params['settings'] = self.settings
        params['main_progressbar'] = self.ui.get_object('progressbar1')
        params['alternate_package_list'] = ""
        params['testing'] = cmd_line.testing

        self.pages["language"] = language.Language(params)
        self.pages["location"] = location.Location(params)
        self.pages["check"] = check.Check(params)
        self.pages["keymap"] = keymap.Keymap(params)
        self.pages["timezone"] = timezone.Timezone(params)
        self.pages["installation_ask"] = installation_ask.InstallationAsk(
            params)
        self.pages[
            "installation_automatic"] = installation_automatic.InstallationAutomatic(
                params)
        self.pages[
            "installation_alongside"] = installation_alongside.InstallationAlongside(
                params)
        self.pages[
            "installation_advanced"] = installation_advanced.InstallationAdvanced(
                params)
        self.pages["user_info"] = user_info.UserInfo(params)
        self.pages["slides"] = slides.Slides(params)

        self.connect("delete-event", Gtk.main_quit)
        self.ui.connect_signals(self)

        self.set_title(_('Manjaro Installer'))
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_resizable(False)
        self.set_size_request(MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT)

        # Set window icon
        icon_dir = os.path.join(data_dir, 'manjaro-icon.png')

        self.set_icon_from_file(icon_dir)

        # Set the first page to show
        self.current_page = self.pages["language"]

        self.main_box.add(self.current_page)

        # Header style testing

        style_provider = Gtk.CssProvider()

        style_css = os.path.join(data_dir, "css", "gtk-style.css")

        with open(style_css, 'rb') as css:
            css_data = css.read()

        style_provider.load_from_data(css_data)

        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(), style_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

        # Show main window
        self.show_all()

        self.current_page.prepare('forwards')

        # Hide backwards button
        self.backwards_button.hide()

        # Hide titlebar but show border decoration
        self.get_window().set_accept_focus(True)
        #self.get_window().set_decorations(Gdk.WMDecoration.BORDER)

        # Hide progress bar as it's value is zero
        self.progressbar.set_fraction(0)
        self.progressbar.hide()
        self.progressbar_step = 1.0 / (len(self.pages) - 2)

        with open(tmp_running, "w") as tmp_file:
            tmp_file.write("Thus %d\n" % 1234)

        GLib.timeout_add(1000,
                         self.pages["slides"].manage_events_from_cb_queue)
示例#12
0
    def __init__(self):
       
        # This allows to translate all py texts (not the glade ones)
        gettext.textdomain(APP)
        gettext.bindtextdomain(APP, DIR)

        locale_code, encoding = locale.getdefaultlocale()
        lang = gettext.translation (APP, DIR, [locale_code], None, True)
        lang.install()

        # With this we can use _("string") to translate
        gettext.install(APP, localedir=DIR, codeset=None, names=[locale_code])

        if os.getuid() != 0:
            show.fatal_error(_('This installer must be run with administrative'
                         ' privileges, and cannot continue without them.'))
        
        # check if we're already running
        tmp_running = "/tmp/.setup-running"
        if os.path.exists(tmp_running):
            show.error(_('You cannot run two instances of this installer.\n\n'
                          'If you are sure that the installer is not already running\n'
                          'you can manually delete the file %s\n'
                          'and run this installer again.') % tmp_running)
            sys.exit(1)
                
        super().__init__()
        
        self.settings = config.Settings()

        self.ui_dir = self.settings.get("UI_DIR")

        if not os.path.exists(self.ui_dir):
            cnchi_dir = os.path.join(os.path.dirname(__file__), './')
            self.settings.set("CNCHI_DIR", cnchi_dir)
            
            ui_dir = os.path.join(os.path.dirname(__file__), 'ui/')
            self.settings.set("UI_DIR", ui_dir)
            
            data_dir = os.path.join(os.path.dirname(__file__), 'data/')
            self.settings.set("DATA_DIR", data_dir)
            
            self.ui_dir = self.settings.get("UI_DIR")
            
        # set enabled desktops
        self.settings.set("desktops", _desktops)

        self.ui = Gtk.Builder()
        self.ui.add_from_file(self.ui_dir + "cnchi.ui")

        self.add(self.ui.get_object("main"))

        self.header = self.ui.get_object("box5")

        self.forward_button = self.ui.get_object("forward_button")

        self.logo = self.ui.get_object("logo")

        logo_dir = os.path.join(self.settings.get("DATA_DIR"), "antergos-logo-mini.png")
                                
        self.logo.set_from_file(logo_dir)

        self.title = self.ui.get_object("title")

        # To honor our css
        self.title.set_name("header")
        self.logo.set_name("header")

        self.main_box = self.ui.get_object("main_box")
        self.progressbar = self.ui.get_object("progressbar1")

        self.forward_button = self.ui.get_object("forward_button")
        self.exit_button = self.ui.get_object("exit_button")
        self.backwards_button = self.ui.get_object("backwards_button")
        
        # Create a queue. Will be used to report pacman messages (pac.py)
        # to the main thread (installer_*.py)
        #self.callback_queue = queue.Queue(0)
        # Doing some tests with a LIFO queue
        #self.callback_queue = queue.LifoQueue(0)
        self.callback_queue = Queue()

        # save in config if we have to use aria2 to download pacman packages
        self.settings.set("use_aria2", _use_aria2)
        if _use_aria2:
            log.debug(_("Cnchi will use pm2ml and aria2 to download packages - EXPERIMENTAL"))

        # load all pages
        # (each one is a screen, a step in the install process)

        self.pages = dict()

        params = dict()
        params['title'] = self.title
        params['ui_dir'] = self.ui_dir
        params['forward_button'] = self.forward_button
        params['backwards_button'] = self.backwards_button
        params['exit_button'] = self.exit_button
        params['callback_queue'] = self.callback_queue
        params['settings'] = self.settings
        params['alternate_package_list'] = _alternate_package_list
        params['enable_alongside'] = _enable_alongside
        
        if len(_alternate_package_list) > 0:
            log.debug(_("Using '%s' file as package list") % _alternate_package_list)
        
        self.pages["welcome"] = welcome.Welcome(params)
        self.pages["language"] = language.Language(params)
        self.pages["location"] = location.Location(params)
        self.pages["check"] = check.Check(params)
        self.pages["desktop"] = desktop.DesktopAsk(params)
        self.pages["keymap"] = keymap.Keymap(params)
        self.pages["timezone"] = timezone.Timezone(params)
        self.pages["installation_ask"] = installation_ask.InstallationAsk(params)
        self.pages["installation_automatic"] = installation_automatic.InstallationAutomatic(params)
        self.pages["installation_alongside"] = installation_alongside.InstallationAlongside(params)
        self.pages["installation_advanced"] = installation_advanced.InstallationAdvanced(params)
        self.pages["user_info"] = user_info.UserInfo(params)
        self.pages["slides"] = slides.Slides(params)

        self.connect("delete-event", Gtk.main_quit)
        self.ui.connect_signals(self)

        self.set_title(_('Antergos Installer'))
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_resizable(False)
        self.set_size_request(_main_window_width, _main_window_height);

        # set window icon
        icon_dir = os.path.join(self.settings.get("DATA_DIR"), 'antergos-icon.png')
        
        self.set_icon_from_file(icon_dir)

        # set the first page to show
        self.current_page = self.pages["welcome"]

        self.main_box.add(self.current_page)

        # Header style testing
        style_provider = Gtk.CssProvider()

        style_css = os.path.join(self.settings.get("DATA_DIR"), "css", "gtk-style.css")

        with open(style_css, 'rb') as css:
            css_data = css.read()

        style_provider.load_from_data(css_data)

        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(), style_provider,     
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
        )

        # show main window
        self.show_all()

        self.current_page.prepare('forwards')

        # hide backwards button
        self.backwards_button.hide()

        # Hide titlebar but show border decoration
        self.get_window().set_accept_focus(True)
        self.get_window().set_decorations(Gdk.WMDecoration.BORDER)
        
        # hide progress bar as it's value is zero
        self.progressbar.set_fraction(0)
        self.progressbar.hide()
        self.progressbar_step = 1.0 / (len(self.pages) - 2)

        # we drop privileges, but where we should do it? before this? ¿?
        misc.drop_privileges()

        with open(tmp_running, "wt") as tmp_file:
            tmp_file.write("Cnchi %d\n" % 1234)

        GLib.timeout_add(100, self.pages["slides"].manage_events_from_cb_queue)
示例#13
0
文件: ,.py 项目: 0x202036/word_api
#     chaci = yanzheng.get_send_data()
#     finly = send.Send(chaci[0], chaci[1], chaci[2], chaci[3])
#     back_json = send.Send.to_dict(finly)
#     # 将目前对象转换为字典
#     print(back_json)
#     return jsonify(back_json)
# else:return jsonify(fankui)
my_json = {
    "security": {
        "uname": "amy",
        "key": 12323,
        "time": 2321
    },
    "word": "a",
    "option": {
        "level": 1
    }
}
obj_receive = receive.Receive(my_json)
print(obj_receive.option.level)
obj_check = check.Check(receive=obj_receive)
result = obj_check.begin_check()
if result == "safe":
    print(1)
else:
    obj_db_manager = db_manager.Db_Manager(receive=obj_receive)
    obj_get_word_data = obj_db_manager.get_send_data()
    obj_send = send.Send(obj_get_word_data[0], obj_get_word_data[1],
                         obj_get_word_data[2], obj_get_word_data[3])
    print(obj_send)
    # fasong = get_send_json(obj_send)