コード例 #1
0
ファイル: main.py プロジェクト: klemo/letssharebooks
    def lets_share(self):
        self.lets_share_button.setEnabled(False)
        self.timer.stop()
        self.us.share_button_text = "Connecting..."
        #self.debug_log.addItem("Let's share!")
        self.us.counter = 0
        self.us.lost_connection = False

        if not self.us.ssh_proc:
            self.main_gui.start_content_server()
            opts, args = server_config().option_parser().parse_args(['calibre-server'])
            self.calibre_server_port = opts.port

            if sys.platform == "win32":
                self.win_reg = subprocess.Popen("regedit /s .hosts.reg")
                self.us.win_port = int(random.random()*40000+10000)
                self.us.ssh_proc = subprocess.Popen("lsbtunnel.exe -N -T tunnel@{2} -R {0}:localhost:{1} -P 722".format(self.us.win_port, self.calibre_server_port, prefs['lsb_server']), shell=True)
                self.us.lsb_url = "https://www{0}.{1}".format(self.us.win_port, prefs['lsb_server'])
                #_dev_self.us.lsb_url = "http://www{0}.{1}".format(self.us.win_port, prefs['lsb_server'])
                self.us.lsb_url_text = "Go to: {0}".format(self.us.lsb_url)
                self.us.found_url = True
            else:
                self.us.ssh_proc = subprocess.Popen(['ssh', '-T', '-N', '-g', '-o', 'UserKnownHostsFile=.userknownhostsfile', '-o', 'TCPKeepAlive=yes', '-o', 'ServerAliveINterval=60', prefs['lsb_server'], '-l', 'tunnel', '-R', '0:localhost:{0}'.format(self.calibre_server_port), '-p', '722'])
                self.us.found_url = None
            
            self.qaction.setIcon(get_icon('images/icon_connected.png'))
            self.us.connecting = True
            self.us.connecting_now = datetime.datetime.now()
            self.timer.start(self.timer_period)
コード例 #2
0
    def lets_share(self):
        self.lets_share_button.setEnabled(False)
        self.timer.stop()
        self.us.share_button_text = "Connecting..."
        #self.debug_log.addItem("Let's share!")
        self.us.counter = 0
        self.us.lost_connection = False

        if not self.us.ssh_proc:
            self.main_gui.start_content_server()
            opts, args = server_config().option_parser().parse_args(['calibre-server'])
            self.calibre_server_port = opts.port

            if sys.platform == "win32":
                self.win_reg = subprocess.Popen("regedit /s .hosts.reg")
                self.us.win_port = int(random.random()*40000+10000)
                self.us.ssh_proc = subprocess.Popen("lsbtunnel.exe -N -T tunnel@{2} -R {0}:localhost:{1} -P 722".format(self.us.win_port, self.calibre_server_port, prefs['lsb_server']), shell=True)
                self.us.lsb_url = "https://www{0}.{1}".format(self.us.win_port, prefs['lsb_server'])
                #_dev_self.us.lsb_url = "http://www{0}.{1}".format(self.us.win_port, prefs['lsb_server'])
                self.us.lsb_url_text = "Go to: {0}".format(self.us.lsb_url)
                self.us.found_url = True
            else:
                self.us.ssh_proc = subprocess.Popen(['ssh', '-T', '-N', '-g', '-o', 'UserKnownHostsFile=.userknownhostsfile', '-o', 'TCPKeepAlive=yes', '-o', 'ServerAliveINterval=60', prefs['lsb_server'], '-l', 'tunnel', '-R', '0:localhost:{0}'.format(self.calibre_server_port), '-p', '722'])
                self.us.found_url = None
            
            self.qaction.setIcon(get_icon('images/icon_connected.png'))
            self.us.connecting = True
            self.us.connecting_now = datetime.datetime.now()
            self.timer.start(self.timer_period)
コード例 #3
0
    def disconnect_all(self):
        #- send gotcha=False to check_connection to exit -------------------------------------------
        self.check_connection.gotcha = False
        connection_thread = self.check_connection.wait(2000)
        if not connection_thread:
            print("check_connection still running! it shouldn't!")

        if sys.platform == "win32":
            try:
                subprocess.Popen("taskkill /f /im lsbtunnel.exe", shell=True)
            except Exception as e:
                self.debug_label.setText(str(e))
        else:
            try:
                self.ssh_proc.kill()
            except Exception as e:
                self.debug_label.setText(str(e))
        try:
            self.main_gui.content_server.exit()
        except Exception as e:
            self.debug_label.setText(str(e))

        self.main_gui.content_server = None
        self.qaction.setIcon(get_icon('images/icon.png'))
        self.lsb_url_text = "Be a librarian. Share your library."
        self.url_label_tooltip = '<<<< Be a librarian. Click on Start sharing button.'

        self.lsb_url = "nourl"
        self.ssh_proc = None
        self.initial = True
コード例 #4
0
ファイル: ui.py プロジェクト: klemo/letssharebooks
    def genesis(self):
        icon_resources = self.load_resources(PLUGIN_ICONS)
        set_plugin_icon_resources(self.name, icon_resources)
        #icon = get_icons(['images/icon.png', 'images/icon_c.png')

        self.qaction.setIcon(get_icon(PLUGIN_ICONS[0]))
        #self.menu = QMenu(self.gui)
        self.old_actions_unique_map = {}
        #self.qaction.setMenu(self.menu)
        self.us = UnitedStates()
        self.qaction.triggered.connect(self.show_dialog)
コード例 #5
0
ファイル: ui.py プロジェクト: nikolaplejic/letssharebooks
    def genesis(self):
        icon_resources = self.load_resources(PLUGIN_ICONS)
        set_plugin_icon_resources(self.name, icon_resources)
        #icon = get_icons(['images/icon.png', 'images/icon_c.png')

        self.qaction.setIcon(get_icon(PLUGIN_ICONS[0]))
        #self.menu = QMenu(self.gui)
        self.old_actions_unique_map = {}
        #self.qaction.setMenu(self.menu)
        self.us = UnitedStates()
        self.qaction.triggered.connect(self.show_dialog)
コード例 #6
0
 def check_connections(self):
     #self.webview.show()
     if self.initial:
         print("initial!")
         self.us.library_changed_emit()
         self.initial = False
     self.qaction.setIcon(get_icon('images/icon_connected.png'))
     self.check_connection.add_urls(["http://localhost:{}".format(self.calibre_server_port), self.lsb_url])
     self.check_connection.gotcha = True
     if not self.check_connection.isRunning():
         print("check_connection.start!")
         self.check_connection.start()
コード例 #7
0
ファイル: main.py プロジェクト: klemo/letssharebooks
    def stop_share(self):
        self.stop_share_button.setEnabled(False)
        #self.debug_log.addItem("Stop Share!")
        self.timer.stop()
        self.us.lsb_url = 'nourl'
        self.us.urllib_result = ''
        self.us.disconnecting = True

        self.qaction.setIcon(get_icon('images/icon.png'))
        
        self.kill_servers_thread.start()

        self.timer.start(self.timer_period)
コード例 #8
0
    def stop_share(self):
        self.stop_share_button.setEnabled(False)
        #self.debug_log.addItem("Stop Share!")
        self.timer.stop()
        self.us.lsb_url = 'nourl'
        self.us.urllib_result = ''
        self.us.disconnecting = True

        self.qaction.setIcon(get_icon('images/icon.png'))
        
        self.kill_servers_thread.start()

        self.timer.start(self.timer_period)
コード例 #9
0
    def genesis(self):
        icon_resources = self.load_resources(PLUGIN_ICONS)
        set_plugin_icon_resources(self.name, icon_resources)

        self.qaction.setIcon(get_icon(PLUGIN_ICONS[0]))
        self.old_actions_unique_map = {}
        self.us = UnitedStates()

        res = self.load_resources(PORTABLE_RESOURCES)

        os.makedirs(os.path.join(self.us.portable_directory,
                                 'portable'))
        os.makedirs(os.path.join(self.us.portable_directory,
                                 'portable/bootstrap'))
        os.makedirs(os.path.join(self.us.portable_directory,
                                 'portable/bootstrap/css'))
        os.makedirs(os.path.join(self.us.portable_directory,
                                 'portable/bootstrap/js'))
        os.makedirs(os.path.join(self.us.portable_directory,
                                 'portable/bootstrap/fonts'))

        for resource in res.keys():
            if resource == "portable/libraries.js":
                lib_lines = res[resource].split(os.linesep)
                lib_lines.insert(4, "var PORTABLE = true;{}".format(os.linesep))
                with open(os.path.join(self.us.portable_directory,
                                       'portable/libraries.js'), "w") as lib:
                    lib.writelines(os.linesep.join(lib_lines))
            else:
                with open(os.path.join(self.us.portable_directory,
                                       resource), 'wb') as portable:
                    portable.write(res[resource])

        self.popup_type = QToolButton.InstantPopup
        base_plugin_object = self.interface_action_base_plugin
        do_user_config = base_plugin_object.do_user_config

        self.d = LetsShareBooksDialog(self.gui,
                                      self.qaction.icon(),
                                      do_user_config,
                                      self.qaction, self.us)
        m = QMenu(self.gui)
        self.qaction.setMenu(m)
        a = QWidgetAction(m)
        a.setDefaultWidget(self.d)
        m.addAction(a)
コード例 #10
0
    def genesis(self):
        icon_resources = self.load_resources(PLUGIN_ICONS)
        set_plugin_icon_resources(self.name, icon_resources)

        self.qaction.setIcon(get_icon(PLUGIN_ICONS[0]))
        self.old_actions_unique_map = {}
        self.us = UnitedStates()

        res = self.load_resources(PORTABLE_RESOURCES)

        os.makedirs(os.path.join(self.us.portable_directory, 'portable'))
        os.makedirs(
            os.path.join(self.us.portable_directory, 'portable/bootstrap'))
        os.makedirs(
            os.path.join(self.us.portable_directory, 'portable/bootstrap/css'))
        os.makedirs(
            os.path.join(self.us.portable_directory, 'portable/bootstrap/js'))
        os.makedirs(
            os.path.join(self.us.portable_directory,
                         'portable/bootstrap/fonts'))

        for resource in res.keys():
            if resource == "portable/libraries.js":
                lib_lines = res[resource].split(os.linesep)
                lib_lines.insert(4,
                                 "var PORTABLE = true;{}".format(os.linesep))
                with open(
                        os.path.join(self.us.portable_directory,
                                     'portable/libraries.js'), "w") as lib:
                    lib.writelines(os.linesep.join(lib_lines))
            else:
                with open(os.path.join(self.us.portable_directory, resource),
                          'wb') as portable:
                    portable.write(res[resource])

        self.popup_type = QToolButton.InstantPopup
        base_plugin_object = self.interface_action_base_plugin
        do_user_config = base_plugin_object.do_user_config

        self.d = LetsShareBooksDialog(self.gui, self.qaction.icon(),
                                      do_user_config, self.qaction, self.us)
        m = QMenu(self.gui)
        self.qaction.setMenu(m)
        a = QWidgetAction(m)
        a.setDefaultWidget(self.d)
        m.addAction(a)
コード例 #11
0
ファイル: ui.py プロジェクト: PabloCastellano/letssharebooks
    def genesis(self):
        icon_resources = self.load_resources(PLUGIN_ICONS)
        set_plugin_icon_resources(self.name, icon_resources)

        self.qaction.setIcon(get_icon(PLUGIN_ICONS[0]))
        self.old_actions_unique_map = {}
        self.us = UnitedStates()

        self.popup_type = QToolButton.InstantPopup
        base_plugin_object = self.interface_action_base_plugin
        do_user_config = base_plugin_object.do_user_config

        d = LetsShareBooksDialog(self.gui, self.qaction.icon(), do_user_config, self.qaction, self.us)
        m = QMenu(self.gui)
        self.qaction.setMenu(m)
        a = QWidgetAction(m)
        a.setDefaultWidget(d)
        m.addAction(a)
コード例 #12
0
ファイル: ui.py プロジェクト: gitter-badger/letssharebooks
    def genesis(self):
        icon_resources = self.load_resources(PLUGIN_ICONS)
        set_plugin_icon_resources(self.name, icon_resources)

        self.qaction.setIcon(get_icon(PLUGIN_ICONS[0]))
        self.old_actions_unique_map = {}
        self.us = UnitedStates()

        res = self.load_resources(PORTABLE_RESOURCES)
        os.makedirs(os.path.join(self.us.portable_directory, 'portable'))
        for resource in res.keys():
            #logger.debug("RESOURCE KEY: {}".format(resource))
            if sys.platform == "win32" and resource == "portable/portable_win.js":
                #logger.debug("WIN_RESOURCE KEY: {}".format(resource))
                with open(os.path.join(self.us.portable_directory,
                                       'portable/portable.js'), 'w') as portable:
                    portable.write(res[resource])
            elif sys.platform == "win32" and resource == "portable/portable.js":
                #logger.debug("IGNORE {} ON WINDOWS".format(resource))
                pass
            else:
                with open(os.path.join(self.us.portable_directory,
                                       resource), 'wb') as portable:
                    portable.write(res[resource])

        self.popup_type = QToolButton.InstantPopup
        base_plugin_object = self.interface_action_base_plugin
        do_user_config = base_plugin_object.do_user_config

        self.d = LetsShareBooksDialog(self.gui,
                                      self.qaction.icon(),
                                      do_user_config,
                                      self.qaction, self.us)
        m = QMenu(self.gui)
        self.qaction.setMenu(m)
        a = QWidgetAction(m)
        a.setDefaultWidget(self.d)
        m.addAction(a)