예제 #1
0
 def start(self,
           dash_path="/",
           static_path="/static",
           static_directory="static"):
     grapp_server.mount(dash_path, WSGIMiddleware(self.app.server))
     grapp_server.mount(static_path,
                        StaticFiles(directory=static_directory),
                        name="static")
     browser(
         f'http://{"localhost" if self.host == "0.0.0.0" else self.host}:{self.port}'
     )
     uvicorn.run(grapp_server, host=self.host, port=self.port)
예제 #2
0
def handleLogin(*args):
    app = App()

    @app.route("/save_config")
    async def index(request: Request):
        with open(_CONFIGPATH, 'w+') as file:
            config = str(await request.content, encoding='utf-8')
            file.write(config)

        return json_response(data={'message': 'Config saved succesfully'})

    browser("http://transferpi.tk/login")
    print("* Press Ctrl + C to exit after saving config")
    try:
        app.serve(**{"host": "localhost", "port": 2121})
    except KeyboardInterrupt:
        exit()
예제 #3
0
        # destroy object to verify later if card was removed
        del smart

        ### Handling options
        if op == '1':  # login/logout
            core.logout() if core.loggedIn else core.login()

        elif op == '2' and core.loggedIn:  # personal info
            core.show_my_info()
        elif op == '3' and core.loggedIn:  # show my purchases
            core.list_my_content()
        elif op == '4' and core.loggedIn:  # play some content
            core.play_my_content()
        elif op == '5' and core.loggedIn:  # go to webpage
            browser(api.HOMEPAGE)


        elif op == 'x':
            print co.BOLD + co.HEADER + "Terminated by user! See you soon." + co.ENDC
            sys.exit(0)
        else:
            print co.WARNING + "\nInvalid option, sorry!" + co.ENDC

except KeyboardInterrupt:
    print co.FAIL + "\n\nProgram interrupted by user. Bye!" + co.ENDC
    sys.exit(1)
except Exception as e:
    print co.FAIL + "Oops, unexpected error!\n{0}".format(e) + co.ENDC
    sys.exit(2)
예제 #4
0
 def url_click(self, url):
     full = "http://127.0.0.1:" + \
         getConfigValue(self.service.config, "ui_port", "43110") + "/" + url
     print("Opening in browser %s" % full)
     browser(full)
예제 #5
0
#!/usr/bin/env python

from webbrowser import open as browser
from json import load
from sys import argv

if len(argv) > 1:
    for file in argv[1:]:
        with open(file) as f:
            data = load(f)
        browser(data['url'])
else:
    browser('https://docs.google.com/')
예제 #6
0
    def baseUI(self):
        self.root.title("Sauce Finder")
        self.img_tmp = ImageTk.PhotoImage(Image.open("tmep.png"))

        head_f = tk.Frame(self, borderwidth=3, relief='ridge')

        # header
        header = tk.Label(head_f,
                          width=80,
                          text="Sauce Finder",
                          font=(None, 15))

        # 2nd line frame
        sub_f = tk.Frame(head_f)

        # input frame
        input_f = tk.Frame(sub_f)
        prompt = tk.Label(input_f, text="Enter Number")
        self.entry = tk.Entry(input_f, width=8)
        self.entry.bind("<FocusIn>",
                        lambda event: self.entry.selection_range(0, tk.END))
        self.entry.bind("<Return>", lambda event: self.fetchSauce())
        self.search = tk.Button(input_f,
                                width=6,
                                text="search",
                                command=self.fetchSauce)

        # settings
        settings_b = tk.Button(sub_f,
                               width=10,
                               text="settings",
                               command=lambda: Settings(self))

        # sub headers
        self.title_l = tk.Label(self,
                                text=" ",
                                font=(None, 14),
                                wraplength=875)
        self.subtitle_l = tk.Label(self,
                                   text=" ",
                                   font=(None, 13),
                                   wraplength=875)

        # preview frame
        preview_f = tk.Frame(self)
        self.cover_l = tk.Label(preview_f, image=self.img_tmp)
        side_f = tk.Frame(preview_f)
        self.fields_f = tk.Frame(side_f)

        # bottom part under tags
        self.footer = tk.Frame(side_f)
        options_f = tk.Frame(self.footer)
        view_b = tk.Button(options_f,
                           width=10,
                           text="View",
                           command=self.viewBook)
        link_b = tk.Button(
            options_f,
            width=10,
            text="Link",
            command=lambda: browser(
                f"https://nhentai.net/g/{self.sauce_data['number']}/"))
        self.down_b = tk.Button(options_f,
                                width=10,
                                text="Save",
                                command=self.save)

        # download status frame
        self.status_f = tk.Frame(self.footer)
        self.s_l = tk.Label(self.status_f, width=11)
        self.down_l = tk.Label(self.status_f, width=7)
        bar_container = tk.Frame(self.status_f, height=20, width=150, bg='red')
        self.bar = tk.Frame(bar_container, height=20, width=0, bg='green')

        # yikes
        self.pack(padx=(30, 30))

        head_f.grid(row=0, pady=(15, 0))
        header.grid(row=0, column=0, pady=(5, 5))

        sub_f.grid(row=1, column=0, sticky="ew", pady=(0, 5))
        sub_f.grid_columnconfigure(0, weight=1)
        sub_f.grid_columnconfigure(2, weight=1)
        input_f.grid(row=0, column=1, padx=(20 + 10 * 8, 0))
        prompt.grid(row=0, column=0, padx=(5, 5))
        self.entry.grid(row=0, column=1, padx=(5, 5))
        self.search.grid(row=0, column=2, padx=(5, 5))

        settings_b.grid(row=0, column=2, sticky="e", padx=(0, 20))

        self.title_l.grid(row=1, column=0, pady=(15, 2), sticky='ew')
        self.subtitle_l.grid(row=2, column=0, pady=(5, 10), sticky='ew')

        preview_f.grid(row=3, pady=(5, 15), sticky='ew')
        self.cover_l.grid(row=0, column=0, padx=(10, 10), sticky='nw')
        side_f.grid(row=0, column=1, padx=(0, 10), sticky='n')
        self.fields_f.grid(row=0, sticky='nw')
        options_f.grid(row=0, pady=(0, 10))
        view_b.grid(row=0, column=0, padx=(20, 20))
        link_b.grid(row=0, column=1, padx=(20, 20))
        self.down_b.grid(row=0, column=2, padx=(20, 20))

        self.s_l.grid(row=0, column=0, padx=(20, 0), sticky='w')
        self.down_l.grid(row=0, column=1, padx=(0, 5), sticky='e')
        bar_container.grid(row=0, column=2, padx=(0, 15), sticky='w')
        bar_container.grid_propagate(0)
        self.bar.grid(sticky='w')
        tk.Button(self.status_f, text="cancel",
                  command=self.stop).grid(row=0, column=3)