Esempio n. 1
0
    def req_update_handler(self):
        req = urlparse.urlparse(self.path).query
        reqs = urlparse.parse_qs(req, keep_blank_values=True)
        data = ''

        if reqs['cmd'] == ['get_info']:
            data = update_from_github.update_info
            if data == '' or data[0] != '{':
                data = '{"type":"%s"}' % data
        elif reqs['cmd'] == ['set_info']:
            update_from_github.update_info = reqs['info'][0]
            data = '{"res":"success"}'
        elif reqs['cmd'] == ['start_check']:
            update_from_github.init_update_info(reqs['check_update'][0])
            update.check_update()
            data = '{"res":"success"}'
        elif reqs['cmd'] == ['get_progress']:
            data = json.dumps(update_from_github.progress)
        elif reqs['cmd'] == ['get_new_version']:
            current_version = update_from_github.current_version()
            github_versions = update_from_github.get_github_versions()
            data = '{"res":"success", "test_version":"%s", "stable_version":"%s", "current_version":"%s"}' % (github_versions[0][1], github_versions[1][1], current_version)
            xlog.info("%s", data)
        elif reqs['cmd'] == ['update_version']:
            version = reqs['version'][0]
            update_from_github.start_update_version(version)
            data = '{"res":"success"}'
        self.send_response('text/html', data)
Esempio n. 2
0
    def req_update_handler(self):
        req = urlparse.urlparse(self.path).query
        reqs = urlparse.parse_qs(req, keep_blank_values=True)
        data = ''

        if reqs['cmd'] == ['get_info']:
            data = update_from_github.update_info
            if data == '' or data[0] != '{':
                data = '{"type":"%s"}' % data
        elif reqs['cmd'] == ['set_info']:
            update_from_github.update_info = reqs['info'][0]
            data = '{"res":"success"}'
        elif reqs['cmd'] == ['start_check']:
            update_from_github.init_update_info(reqs['check_update'][0])
            update.check_update()
            data = '{"res":"success"}'
        elif reqs['cmd'] == ['get_progress']:
            data = json.dumps(update_from_github.progress)
        elif reqs['cmd'] == ['get_new_version']:
            current_version = update_from_github.current_version()
            github_versions = update_from_github.get_github_versions()
            data = '{"res":"success", "test_version":"%s", "stable_version":"%s", "current_version":"%s"}' % (
                github_versions[0][1], github_versions[1][1], current_version)
            xlog.info("%s", data)
        elif reqs['cmd'] == ['update_version']:
            version = reqs['version'][0]
            update_from_github.start_update_version(version)
            data = '{"res":"success"}'
        self.send_response('text/html', data)
Esempio n. 3
0
    def req_update_handler(self):
        req = urlparse.urlparse(self.path).query
        reqs = urlparse.parse_qs(req, keep_blank_values=True)
        data = ''

        if reqs['cmd'] == ['get_info']:
            data = update_from_github.update_info
            if data == '' or data[0] != '{':
                data = '{"type":"%s"}' % data
        elif reqs['cmd'] == ['set_info']:
            update_from_github.update_info = reqs['info'][0]
            data = '{"res":"success"}'
        elif reqs['cmd'] == ['start_check']:
            update_from_github.init_update_info(reqs['check_update'][0])
            update.check_update()
            data = '{"res":"success"}'
        elif reqs['cmd'] == ['get_progress']:
            data = json.dumps(update_from_github.progress)
        elif reqs['cmd'] == ['get_new_version']:
            current_version = update_from_github.current_version()
            github_versions = update_from_github.get_github_versions()
            data = '{"res":"success", "test_version":"%s", "stable_version":"%s", "current_version":"%s"}' % (
                github_versions[0][1], github_versions[1][1], current_version)
            xlog.info("%s", data)
        elif reqs['cmd'] == ['update_version']:
            version = reqs['version'][0]

            checkhash = 1
            if 'checkhash' in reqs and reqs['checkhash'][0] == '0':
                checkhash = 0

            update_from_github.start_update_version(version, checkhash)
            data = '{"res":"success"}'
        elif reqs['cmd'] == ['set_localversion']:
            version = reqs['version'][0]

            if update_from_github.update_current_version(version):
                data = '{"res":"success"}'
            else:
                data = '{"res":"false", "reason": "version not exist"}'
        elif reqs['cmd'] == ['get_localversions']:
            local_versions = update_from_github.get_local_versions()

            s = ""
            for v in local_versions:
                if not s == "":
                    s += ","
                s += ' { "v":"%s" } ' % (v)
            data = '[  %s  ]' % (s)
        elif reqs['cmd'] == ['del_localversion']:
            if update_from_github.del_version(reqs['version'][0]):
                data = '{"res":"success"}'
            else:
                data = '{"res":"fail"}'

        self.send_response('text/html', data)
Esempio n. 4
0
    def req_update_handler(self):
        req = urlparse.urlparse(self.path).query
        reqs = urlparse.parse_qs(req, keep_blank_values=True)
        data = ''

        if reqs['cmd'] == ['get_info']:
            data = update_from_github.update_info
            if data == '' or data[0] != '{':
                data = '{"type":"%s"}' % data
        elif reqs['cmd'] == ['set_info']:
            update_from_github.update_info = reqs['info'][0]
            data = '{"res":"success"}'
        elif reqs['cmd'] == ['start_check']:
            update_from_github.init_update_info(reqs['check_update'][0])
            update.check_update()
            data = '{"res":"success"}'
        elif reqs['cmd'] == ['get_progress']:
            data = json.dumps(update_from_github.progress)
        elif reqs['cmd'] == ['get_new_version']:
            current_version = update_from_github.current_version()
            github_versions = update_from_github.get_github_versions()
            data = '{"res":"success", "test_version":"%s", "stable_version":"%s", "current_version":"%s"}' % (github_versions[0][1], github_versions[1][1], current_version)
            xlog.info("%s", data)
        elif reqs['cmd'] == ['update_version']:
            version = reqs['version'][0]

            checkhash = 1
            if 'checkhash' in reqs and reqs['checkhash'][0] == '0':
                checkhash = 0

            update_from_github.start_update_version(version, checkhash)
            data = '{"res":"success"}'
        elif reqs['cmd'] == ['set_localversion']:
            version = reqs['version'][0]

            if update_from_github.update_current_version(version):
                data = '{"res":"success"}'
            else:
                data = '{"res":"false", "reason": "version not exist"}'
        elif reqs['cmd'] == ['get_localversions']:
            local_versions = update_from_github.get_local_versions()
            
            s = ""
            for v in local_versions:
                if not s == "":
                    s += ","
                s += ' { "v":"%s" } ' % (v)
            data = '[  %s  ]' %(s)
        elif reqs['cmd'] == ['del_localversion']:
            if update_from_github.del_version( reqs['version'][0] ):
                data = '{"res":"success"}'
            else:
                data = '{"res":"fail"}'
            
            
        self.send_response('text/html', data)
Esempio n. 5
0
def main():
    args = parse_args()

    init_logging(args.debug)
    config.init()
    models.database.init(args.debug)
    models.avatar.init()
    models.translate.init()
    api.chat.init()
    update.check_update()

    run_server(args.host, args.port, args.debug)
Esempio n. 6
0
    def test_check_update(self):
        """Unit test update.check_update.
        """
        self.enable_unit_test()

        from update import check_update
        from utils import InvalidUpdate

        with self.assertRaisesRegexp(
                InvalidUpdate,
                r'This type of update \(some/dummy_refname,commit\) is '
                'currently unsupported\.'):
            check_update('some/dummy_refname',
                         '8ef2d60c830f70e70268ce886209805f5010db1f',
                         'd065089ff184d97934c010ccd0e7e8ed94cb7165')
Esempio n. 7
0
    def test_check_update(self):
        """Unit test update.check_update.
        """
        self.enable_unit_test()

        from update import check_update
        from utils import InvalidUpdate

        with self.assertRaisesRegexp(
                InvalidUpdate,
                r'Unable to determine the type of reference for: '
                'some/dummy_refname'):
            check_update('some/dummy_refname',
                         '8ef2d60c830f70e70268ce886209805f5010db1f',
                         'd065089ff184d97934c010ccd0e7e8ed94cb7165')
Esempio n. 8
0
def main():
    parser = argparse.ArgumentParser(
        description='用于OBS的仿YouTube风格的bilibili直播聊天层')
    parser.add_argument('--host',
                        help='服务器host,默认为127.0.0.1',
                        default='127.0.0.1')
    parser.add_argument('--port',
                        help='服务器端口,默认为12450',
                        type=int,
                        default=12450)
    parser.add_argument('--debug', help='调试模式', action='store_true')
    args = parser.parse_args()

    logging.basicConfig(
        format='{asctime} {levelname} [{name}]: {message}',
        datefmt='%Y-%m-%d %H:%M:%S',
        style='{',
        level=logging.INFO if not args.debug else logging.DEBUG)

    asyncio.ensure_future(update.check_update())

    app = tornado.web.Application(
        [(r'/chat', views.chat.ChatHandler),
         (r'/config', views.config.ConfigsHandler),
         (r'/config/(.+)', views.config.ConfigHandler),
         (r'/((css|fonts|img|js|static)/.*)', tornado.web.StaticFileHandler, {
             'path': WEB_ROOT
         }),
         (r'/(favicon\.ico)', tornado.web.StaticFileHandler, {
             'path': WEB_ROOT
         }), (r'/.*', views.main.MainHandler, {
             'path': WEB_ROOT
         })],
        websocket_ping_interval=30,
        debug=args.debug,
        autoreload=False)
    try:
        app.listen(args.port, args.host)
    except OSError:
        logger.warning('Address is used %s:%d', args.host, args.port)
        return
    finally:
        url = 'http://localhost' if args.port == 80 else f'http://localhost:{args.port}'
        webbrowser.open(url)
    logger.info('Server started: %s:%d', args.host, args.port)
    tornado.ioloop.IOLoop.current().start()
Esempio n. 9
0
 def on_check_update(self, widget=None, data=None):
     update.check_update()
Esempio n. 10
0
 def on_check_update(self, widget=None, data=None):
     update.check_update()
Esempio n. 11
0
    print("\nYOU HAVE BEEN WARNED")
    print("Looks like you are not running on GNU/Linux or a Mac")
    print("This program is not guarenteed to work on Windows\n")

from bs4 import BeautifulSoup as bs
import requests

# Define command line arguments
parser = argparse.ArgumentParser(description="Sci-Hub downloader: Utility to \
                                             download from Sci-Hub")
parser.add_argument("target",
                    help="URL/DOI to download PDF", type=str)
parser.add_argument("--view", help="Open article in browser for reading", action="store_true")
args = parser.parse_args()

update.check_update()


# Get Sci-Hub URL from Google
def get_url():
    print("Trying primary method.")
    # Query Google and create soup object.
    response = requests.get("https://www.google.com/search?&q=sci-hub")
    soup = bs(response.content, "lxml")
    # Target url is inside a cite tag.
    url = soup.cite.text
    # Regex check for URL. Returns empty string if
    # no match
    if re.match('http[s]?://sci-hub.[a-z]{2,}', url):
        print("URL from primary method is: " + url + "\n")
        return url
Esempio n. 12
0
from update import check_update
from utils import InvalidUpdate

try:
    check_update(
        "some/dummy_refname",
        "8ef2d60c830f70e70268ce886209805f5010db1f",
        "d065089ff184d97934c010ccd0e7e8ed94cb7165",
    )
    print("*** ERROR: Call to check_update did not raise an exception")
except InvalidUpdate as e:
    print("\n".join(e.args))
Esempio n. 13
0
    def __init__(master):

        master = tk.Tk()
        master.geometry("420x500")
        master.title("Commander Pi")
        master.resizable(False, False)
        th.window_list.append(master)
        mainframe = Frame(master)
        mainframe.pack(padx=10, pady=10)

        titleframe = Frame(mainframe)
        titleframe.pack()

        loadimg = Image.open(home_path +
                             "/CommanderPi/src/icons/title_logo.png")
        img = ImageTk.PhotoImage(image=loadimg)

        img_label = tk.Label(titleframe, image=img)
        img_label.image = img
        img_label.grid(row=0, column=0, columnspan=2)

        #title_label = tk.Label( titleframe, text = "Commander Pi", font=("TkDefaultFont", 22, "bold") )
        #title_label.grid(row=0, column=1)

        separator = ttk.Separator(mainframe, orient='horizontal')
        separator.pack(fill=X, expand=True, pady=10)

        infoframe = Frame(mainframe)
        infoframe.pack(fill=X)

        title2_label = tk.Label(infoframe,
                                text="Real-time system information:\n",
                                font=("TkDefaultFont", 11, "bold"),
                                anchor='w')
        title2_label.grid(row=0, column=0, columnspan=2, sticky=W)

        board_version_label = tk.Label(infoframe,
                                       text=rs.board_version,
                                       fg="red",
                                       anchor='w')
        board_version_label.grid(row=1, column=0, columnspan=2, sticky=W)

        kernel_version_label = tk.Label(infoframe,
                                        text="Kernel version: ",
                                        width=30,
                                        anchor='w')
        kernel_version_label.grid(row=2, column=0, sticky=W)

        kernel_version_label2 = tk.Label(infoframe,
                                         text=rs.kernel_version,
                                         width=15,
                                         anchor='w')
        kernel_version_label2.grid(row=2, column=1)

        processor_architecture_label = tk.Label(
            infoframe, text="Processor architecture: ", width=30, anchor='w')
        processor_architecture_label.grid(row=3, column=0, sticky=W)

        processor_architecture_label2 = tk.Label(
            infoframe, text=rs.processor_architecture, width=15, anchor='w')
        processor_architecture_label2.grid(row=3, column=1)

        memory_use_label = tk.Label(infoframe,
                                    text="Memory usage: ",
                                    width=30,
                                    anchor='w')
        memory_use_label.grid(row=4, column=0, sticky=W)

        memory_use_label2 = tk.Label(infoframe, text="", width=15, anchor='w')
        memory_use_label2.grid(row=4, column=1)

        actual_cpu_temp_label = tk.Label(infoframe,
                                         text="Actual CPU temperature: ",
                                         width=30,
                                         anchor='w')
        actual_cpu_temp_label.grid(row=5, column=0, sticky=W)

        actual_cpu_temp_label2 = tk.Label(infoframe,
                                          text="",
                                          width=15,
                                          anchor='w')
        actual_cpu_temp_label2.grid(row=5, column=1)

        actual_cpu_usage_label = tk.Label(
            infoframe,
            text="Processor frequency usage is: ",
            width=30,
            anchor='w')
        actual_cpu_usage_label.grid(row=6, column=0, sticky=W)

        actual_cpu_usage_label2 = tk.Label(infoframe,
                                           text="",
                                           width=15,
                                           anchor='w')
        actual_cpu_usage_label2.grid(row=6, column=1)

        used_label = tk.Label(infoframe,
                              text="Used disk space: ",
                              width=30,
                              anchor='w')
        used_label.grid(row=7, column=0, sticky=W)

        ##BORDER TO TABLE borderwidth=2, relief="groove",
        used_label2 = tk.Label(infoframe,
                               text=rs.used + "/" + rs.total + " GiB",
                               width=15,
                               anchor='w')
        used_label2.grid(row=7, column=1)

        separator2 = ttk.Separator(mainframe, orient='horizontal')
        separator2.pack(fill=X, expand=True, pady=10)

        #REFRESH CPU USAGE, MEMORY USAGE AND TEMPERATURE
        def refresh():
            #for x in th.window_list:
            #	print(x.__class__)
            ttext = rs.reftemp()
            ptext = rs.refusage()
            mtext = rs.refmem()
            #dtext = str(rs.get_disk_percent())
            #dtext = "CPU usage " + rs.cpu_usagex +" MHz"
            memory_use_label2.configure(text=mtext + "/100%")
            actual_cpu_temp_label2.configure(text=ttext)
            actual_cpu_usage_label2.configure(text=ptext)
            #disk_use_label.configure(text = "Disk space usage" +dtext+"/100%")
            master.after(1000, refresh)

        refresh()

        #fast_overclock_b = Button(master, text="Overclocking for non-advanced", command = lambda:bopen(Fast_Overclock_Window), width=20, cursor="hand2", fg="green")
        #fast_overclock_b.pack(fill=X)

        advanced_label = tk.Label(mainframe,
                                  text="Advanced tools",
                                  font=("TkDefaultFont", 11, "bold"),
                                  anchor='w')
        advanced_label.pack(fill=X)

        btn_frame = Frame(mainframe)
        btn_frame.pack(fill=X)

        photo1 = PhotoImage(file=home_path + "/CommanderPi/src/icons/CPUs.png")
        #photoimage1 = photo1.subsample(15, 15)

        proc_info_button = Button(btn_frame,
                                  text="CPU details",
                                  command=lambda: bopen(Proc_Info_Window),
                                  width=60,
                                  height=80,
                                  cursor="hand2",
                                  image=photo1,
                                  compound=TOP)
        proc_info_button.grid(row=0, column=0, padx=4)

        photo2 = PhotoImage(file=home_path +
                            "/CommanderPi/src/icons/Bootloaders.png")

        btn4 = Button(btn_frame,
                      text="Bootloader",
                      command=lambda: bopen(Bootloader_Info_Window),
                      width=60,
                      height=80,
                      cursor="hand2",
                      image=photo2,
                      compound=TOP)
        btn4.grid(row=0, column=1, padx=4)

        photo3 = PhotoImage(file=home_path +
                            "/CommanderPi/src/icons/Networkings.png")

        btn5 = Button(btn_frame,
                      text="Network",
                      command=lambda: bopen(Network_Window),
                      width=60,
                      height=80,
                      cursor="hand2",
                      image=photo3,
                      compound=TOP)
        btn5.grid(row=0, column=2, padx=4)

        photo4 = PhotoImage(file=home_path +
                            "/CommanderPi/src/icons/Overclockings.png")

        btn2 = Button(btn_frame,
                      text="Overclock",
                      command=lambda: bopen(Overclock_Window),
                      width=60,
                      height=80,
                      cursor="hand2",
                      image=photo4,
                      compound=TOP)
        btn2.grid(row=0, column=3, padx=4)

        btn3 = Button(mainframe,
                      text="About/Update",
                      command=lambda: bopen(About_Window),
                      font=("TkDefaultFont", 11, "bold"),
                      cursor="hand2")
        btn3.pack(side=BOTTOM, pady=5)

        #d = Info_Window()
        master.protocol("WM_DELETE_WINDOW", lambda: on_Window_Close(master))
        th.set_theme(master)
        up.check_update()
        master.mainloop()
Esempio n. 14
0
 def run(self) -> None:
     self.signal.haveUpdate.emit(check_update(self.verSion))
Esempio n. 15
0
from pip._vendor.distlib.compat import raw_input

from bcode import Bcode
from update import check_update

if __name__ == '__main__':
    check_update()
    user = raw_input("博纳云账号: ")
    password = raw_input("博纳云密码: ")
    bcode = Bcode(user, password)
    bcode.start()