Esempio n. 1
0
    def __init__(self, buffer_id, url, config_dir, arguments, emacs_var_dict,
                 module_path):
        BrowserBuffer.__init__(self, buffer_id, url, config_dir, arguments,
                               emacs_var_dict, module_path, False)

        # Get free port.
        self.port = get_free_port()
        self.http_url = "http://127.0.0.1:{0}".format(get_free_port())
        self.url = url

        arguments_dict = json.loads(arguments)
        self.command = arguments_dict["command"]
        self.start_directory = arguments_dict["directory"]
        self.current_directory = self.start_directory
        self.executing_command = ""
        self.index_file = "{0}/index.html".format(self.http_url)
        self.server_js = os.path.join(os.path.dirname(__file__), "server.js")

        self.buffer_widget.titleChanged.connect(self.change_title)

        http_thread = threading.Thread(target=self.run_http_server, args=())
        http_thread.start()

        self.search_term = ""

        # Start server process.
        args = [
            "node", self.server_js,
            str(self.port), self.start_directory, self.command
        ]
        self.background_process = subprocess.Popen(args,
                                                   stdout=subprocess.PIPE,
                                                   stderr=subprocess.STDOUT,
                                                   shell=False)

        # The background process (server.js) might take time to start.
        # If we open the terminal page before it's up and running, we'll get a
        # "connection refused" error when connecting to the websocket port.
        # User will have to reload the page to get a terminal.
        # Adding this extra step seems to solve this timing problem.
        try:
            outs, errs = self.background_process.communicate(timeout=1)
        except Exception:
            print("Terminal: timed out when communicating with server.js.")

        self.open_terminal_page()

        QTimer.singleShot(250, self.focus_widget)

        self.build_all_methods(self)

        self.timer = QTimer()
        self.timer.start(250)
        self.timer.timeout.connect(self.checking_status)
Esempio n. 2
0
    def __init__(self, buffer_id, url, config_dir, arguments, emacs_var_dict, module_path, call_emacs):
        BrowserBuffer.__init__(self, buffer_id, url, config_dir, arguments, emacs_var_dict, module_path, call_emacs, False, QColor(255, 255, 255, 255))

        # Get free port to render markdown.
        self.port = get_free_port()
        self.url = url

        argument_list = arguments.split("ᛡ")
        self.command = argument_list[0]
        self.start_directory = argument_list[1]

        self.server_js = (os.path.join(os.path.dirname(__file__), "server.js"))

        # Start server process.
        self.background_process = subprocess.Popen(
            "node {0} {1} {2} {3}".format(
                self.server_js,
                self.port,
                "'{}'".format(self.start_directory),
                "'{}'".format(self.command),
                stdout=subprocess.PIPE
            ),
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            shell=True)

        self.load_server()

        self.reset_default_zoom()
Esempio n. 3
0
    def __init__(self, buffer_id, url, config_dir, arguments, emacs_var_dict,
                 module_path):
        BrowserBuffer.__init__(self, buffer_id, url, config_dir, arguments,
                               emacs_var_dict, module_path, False)

        # Get free port.
        self.port = get_free_port()
        self.url = url

        arguments_dict = json.loads(arguments)
        self.command = arguments_dict["command"]
        self.start_directory = arguments_dict["directory"]

        self.index_file = os.path.join(os.path.dirname(__file__), "index.html")
        self.server_js = os.path.join(os.path.dirname(__file__), "server.js")

        # Start server process.
        self.background_process = subprocess.Popen(
            "node {0} {1} '{2}' '{3}'".format(self.server_js, self.port,
                                              self.start_directory,
                                              self.command),
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            shell=True)

        self.open_terminal_page()

        self.reset_default_zoom()

        QTimer.singleShot(250, self.focus_terminal)
Esempio n. 4
0
    def __init__(self, buffer_id, url, config_dir, arguments, emacs_var_dict,
                 module_path):
        BrowserBuffer.__init__(self, buffer_id, url, config_dir, arguments,
                               emacs_var_dict, module_path, False)

        # Get free port.
        self.port = get_free_port()
        self.http_url = "http://127.0.0.1:{0}".format(get_free_port())
        self.url = url

        arguments_dict = json.loads(arguments)
        self.command = arguments_dict["command"]
        self.start_directory = arguments_dict["directory"]
        self.current_directory = self.start_directory
        self.executing_command = ""
        self.index_file = "{0}/index.html".format(self.http_url)
        self.server_js = os.path.join(os.path.dirname(__file__), "server.js")

        self.buffer_widget.titleChanged.connect(self.change_title)

        http_thread = threading.Thread(target=self.run_http_server, args=())
        http_thread.start()

        self.search_term = ""

        # Start server process.
        self.background_process = subprocess.Popen(
            "node {0} {1} '{2}' '{3}'".format(self.server_js, self.port,
                                              self.start_directory,
                                              self.command),
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            shell=True)

        self.open_terminal_page()

        self.reset_default_zoom()

        QTimer.singleShot(250, self.focus_terminal)

        self.build_all_methods(self)

        self.timer = QTimer()
        self.timer.start(250)
        self.timer.timeout.connect(self.checking_status)
    def __init__(self, url, background_color, foreground_color):
        QWidget.__init__(self)

        self.setStyleSheet("background-color: transparent;")

        url = os.path.expanduser(url)

        self.file_name_font = QFont()
        self.file_name_font.setPointSize(24)

        self.file_name_label = QLabel()
        self.file_name_label.setText(
            "Your smartphone file will be shared at\n{0}".format(url))
        self.file_name_label.setFont(self.file_name_font)
        self.file_name_label.setAlignment(Qt.AlignCenter)
        self.file_name_label.setStyleSheet(
            "color: {}".format(foreground_color))

        self.qrcode_label = QLabel()

        self.notify_font = QFont()
        self.notify_font.setPointSize(12)
        self.notify_label = QLabel()
        self.notify_label.setText(
            "Scan the QR code above to upload a file from your smartphone.\nMake sure the smartphone is connected to the same WiFi network as this computer."
        )
        self.notify_label.setFont(self.notify_font)
        self.notify_label.setAlignment(Qt.AlignCenter)
        self.notify_label.setStyleSheet("color: {}".format(foreground_color))

        layout = QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addStretch()
        layout.addWidget(self.qrcode_label, 0, Qt.AlignCenter)
        layout.addSpacing(20)
        layout.addWidget(self.file_name_label, 0, Qt.AlignCenter)
        layout.addSpacing(40)
        layout.addWidget(self.notify_label, 0, Qt.AlignCenter)
        layout.addStretch()

        self.port = get_free_port()
        self.local_ip = get_local_ip()
        self.address = "http://{0}:{1}".format(self.local_ip, self.port)

        self.qrcode_label.setPixmap(
            qrcode.make(self.address, image_factory=Image).pixmap())

        tmp_db_file = os.path.join(tempfile.gettempdir(), "filebrowser.db")
        self.background_process = subprocess.Popen(
            "filebrowser --noauth -d {0} --address {1} -p {2}".format(
                tmp_db_file, self.local_ip, self.port),
            cwd=url,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            shell=True)
    def start_server(self, filename):
        global local_file_path

        local_file_path = filename

        self.port = get_free_port()
        self.local_ip = get_local_ip()
        self.set_address("http://{0}:{1}/{2}".format(self.local_ip, self.port, filename))

        self.sender_thread = threading.Thread(target=self.run_http_server, name='LoopThread')
        self.sender_thread.start()
Esempio n. 7
0
    def __init__(self, buffer_id, url, config_dir, arguments, emacs_var_dict):
        BrowserBuffer.__init__(self, buffer_id, url, config_dir, arguments, emacs_var_dict, False, QColor(255, 255, 255, 255))

        # Get free port to render markdown.
        self.port = get_free_port()
        self.url = url

        # Start wetty process.
        self.background_process = subprocess.Popen(
            "wetty -p {0} --base / --sshuser {1} --sshauth publickey -c bash".format(self.port, getpass.getuser()),
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            shell=True)

        # Add timer make load markdown preview link after grip process start finish.
        threading.Timer(1, self.load_wetty_server).start()

        self.reset_default_zoom()
Esempio n. 8
0
    def __init__(self, buffer_id, url, config_dir, arguments, emacs_var_dict,
                 module_path, call_emacs):
        BrowserBuffer.__init__(self, buffer_id, url, config_dir, arguments,
                               emacs_var_dict, module_path, call_emacs, False)

        # Get free port to render markdown.
        self.port = get_free_port()
        self.url = url

        # Start markdown render process.
        if arguments == "":
            subprocess.Popen("grip {0} {1}".format(url, self.port), shell=True)
        else:
            subprocess.Popen("grip --pass {0} {1} {2}".format(
                arguments, url, self.port),
                             shell=True)

        # Add timer make load markdown preview link after grip process start finish.
        timer = threading.Timer(2, self.load_markdown_server)
        timer.start()
    def __init__(self, buffer_id, url, config_dir, arguments, emacs_var_dict, module_path):
        BrowserBuffer.__init__(self, buffer_id, url, config_dir, arguments, emacs_var_dict, module_path, False)

        self.url = url
        self.preview_file = tempfile.mkstemp(prefix='eaf-', suffix='.html', text=True)[1]
        self.render_js = os.path.join(os.path.dirname(__file__), "render.js")
        self.server_port = get_free_port()
        self.dark_mode = "false"
        if emacs_var_dict["eaf-markdown-dark-mode"] == "true" or \
           (emacs_var_dict["eaf-markdown-dark-mode"] == "follow" and emacs_var_dict["eaf-emacs-theme-mode"] == "dark"):
            self.dark_mode = "true"

        self.draw_progressbar = True

        self.run_render_server()
        self.render()

        self.file_watcher = QFileSystemWatcher()
        self.file_watcher.fileChanged.connect(self.on_file_changed)
        self.file_watcher.addPath(url)
    def __init__(self, buffer_id, url, config_dir, arguments, emacs_var_dict, module_path, call_emacs):
        BrowserBuffer.__init__(self, buffer_id, url, config_dir, arguments, emacs_var_dict, module_path, call_emacs, False, QColor(233, 129, 35, 255))

        # Get free port.
        self.port = get_free_port()
        self.url = url

        argument_list = arguments.split("ᛡ")
        self.command = argument_list[0]
        self.start_directory = argument_list[1]

        self.index_file = os.path.join(os.path.dirname(__file__), "index.html")
        self.server_js = os.path.join(os.path.dirname(__file__), "server.js")

        # Start server process.
        self.background_process = subprocess.Popen(
            "node {0} {1} '{2}' '{3}'".format(self.server_js, self.port, self.start_directory, self.command),
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            shell=True)

        self.open_terminal_page()

        self.reset_default_zoom()