Example #1
0
    def get(self):
        terminal_link = util.get_configuration_value('terminalLink')
        if terminal_link is not None:
            host = self.request.host
            host = host[:host.find(':')]
            terminal_link = terminal_link.replace('[host]', host)

        enable_dropbox = False
        if util.get_configuration_value('dropboxKey', '') != '':
            if util.get_configuration_value('dropboxSecret', '') != '':
                enable_dropbox = True

        enable_sftp = False
        if SFTP is True and util.get_configuration_value('enableSFTP', True):
            enable_sftp = True

        self.set_header('Content-Type', 'text/html')
        self.render(
            'index.html',
            title = 'Dashboard - Cider',
            config = json.dumps({
                'terminal_link': terminal_link,
                'enable_local_file_system': util.get_configuration_value(
                    'enableLocalFileSystem',
                    True
                ),
                'enable_dropbox': enable_dropbox,
                'enable_sftp': enable_sftp
            })
        )
Example #2
0
def main():
    """The main application execution."""
    try:
        thread.start_new_thread(start, ())
        suppress = options.get(
            'suppress',
            util.get_configuration_value('suppressBrowser', False)
        )
        if suppress is False:
            webbrowser.open_new_tab('http://localhost:' + str(
                options.get('port', util.get_configuration_value('port', 3333))
            ))

        while(True):
            time.sleep(10)
    except KeyboardInterrupt:
        sys.exit()
Example #3
0
def start():
    """Starts up the application server."""
    log.msg('Starting server...')
    # pylint: disable=W0142
    application = tornado.web.Application(URLS, **SETTINGS)
    # pylint: enable=W0142
    port = options.get('port', util.get_configuration_value('port', 3333))
    log.msg('Listening on port ' + str(port) + '.')
    application.listen(port)
    tornado.ioloop.IOLoop.instance().start()
Example #4
0
    def get(self):
        """GET request; takes an argument file as the full path of the file to
        load into the editor.
        """
        filename = self.get_file()
        full_filename = os.path.join(util.get_base_path_adjustment(), filename)
        text = ""
        saved = False
        read_only = util.get_configuration_value("readOnly", False)
        if not read_only and os.path.exists(full_filename):
            read_only = not os.access(full_filename, os.W_OK)

        try:
            file_handler = open(full_filename, "r")
            text = file_handler.read()
            file_handler.close()
            saved = True
        except Exception as error:  # pylint: disable=W0703
            log.warn(error)

        self.do_output(text, saved=saved, read_only=read_only)
Example #5
0
    def get(self):
        """GET request; takes arguments file and text for the path of the file
        to save and the content to put in it.
        """
        try:
            filename = self.get_file()
            full_filename = os.path.join(util.get_base_path_adjustment(), filename)
            read_only = util.get_configuration_value("readOnly", False)
            if not read_only and (not os.path.exists(full_filename) or os.access(full_filename, os.W_OK)):
                text = self.get_text()
                file_handler = open(full_filename, "w")
                file_handler.write(text)
                file_handler.close()

                self.broadcast_save(filename)
                self.do_success()
            else:
                self.do_failure()
        except Exception as error:  # pylint: disable=W0703
            log.error(error)
            self.do_failure()
Example #6
0
    def get(self):
        """GET request; takes an argument file as the full path of the file to
        load into the editor.
        """
        filename = self.get_file()
        full_filename = os.path.join(
            util.get_base_path_adjustment(),
            filename
        )
        text = ''
        saved = False
        read_only = util.get_configuration_value('readOnly', False)
        if not read_only and os.path.exists(full_filename):
            read_only = not os.access(full_filename, os.W_OK)

        try:
            file_handler = open(full_filename, 'r')
            text = file_handler.read()
            file_handler.close()
            saved = True
        except Exception as error:  # pylint: disable=W0703
            log.warn(error)

        self.do_output(text, saved = saved, read_only = read_only)
Example #7
0
    def get(self):
        """GET request; takes arguments file and text for the path of the file
        to save and the content to put in it.
        """
        try:
            filename = self.get_file()
            full_filename = os.path.join(
                util.get_base_path_adjustment(),
                filename
            )
            read_only = util.get_configuration_value('readOnly', False)
            if not read_only and (not os.path.exists(full_filename) or os.access(full_filename, os.W_OK)):
                text = self.get_text()
                file_handler = open(full_filename, 'w')
                file_handler.write(text)
                file_handler.close()

                self.broadcast_save(filename)
                self.do_success()
            else:
                self.do_failure()
        except Exception as error:  # pylint: disable=W0703
            log.error(error)
            self.do_failure()
Example #8
0
SFTP = False
try:
    import handlers.sftp
    SFTP = True
except ImportError:
    SFTP = False
    log.warn(' '.join([
        'SFTP support not available.',
        'Check dependent libraries pysftp, paramiko and pycrypto.'
    ]))

SETTINGS = {
    'autoescape': None,
    'cookie_secret': util.get_configuration_value(
        'cookieSecret',
        'aW5zZWN1cmVTZWNyZXQ='
    ),
    'dropbox_consumer_key': util.get_configuration_value('dropboxKey', ''),
    'dropbox_consumer_secret': util.get_configuration_value(
        'dropboxSecret',
        ''
    ),
    'login_url': '/',
    'static_path': os.path.join(util.get_base_path(), 'static'),
    'template_path': os.path.join(util.get_base_path(), 'templates'),
}

URLS = [
    (r'/', handlers.IndexHandler),
    (r'/ws/?', handlers.EditorWebSocketHandler),
    (r'/templates.js', handlers.TemplateHandler)