コード例 #1
0
def main(args):
    import cherrypy
    from config import Common

    cherrypy.config.update(Common.settings)
    desktop = False

    if args and "-d" in args:
        from config import Development
        settings = Development.settings
        args.remove("-d")
    elif args and "-l" in args:
        from config import Desktop
        settings = Desktop.settings
        desktop = True
        args.remove("-l")
    else:
        from config import Production
        settings = Production.settings

    cherrypy.config.update(settings)

    database = Database(
        host=cherrypy.config.configMap[u"global"].get(u"luminotes.db_host"),
        ssl_mode=cherrypy.config.configMap[u"global"].get(
            u"luminotes.db_ssl_mode"),
        data_dir=".",
    )
    ranker = Thread_maker(database, *args)
コード例 #2
0
ファイル: updatedb.py プロジェクト: LimpingNinja/luminotes
def main(args):
    import cherrypy
    from config import Common

    cherrypy.config.update(Common.settings)

    if args and "-d" in args:
        from config import Development
        settings = Development.settings
    elif args and "-l" in args:
        from config import Desktop
        settings = Desktop.settings
    else:
        from config import Production
        settings = Production.settings

    cherrypy.config.update(settings)

    database = Database(
        host=cherrypy.config.configMap[u"global"].get(u"luminotes.db_host"),
        ssl_mode=cherrypy.config.configMap[u"global"].get(
            u"luminotes.db_ssl_mode"),
        data_dir=".",
    )
    initializer = Updater(database, cherrypy.config.configMap)
コード例 #3
0
    def setUp(self):
        # make an in-memory sqlite database to use during testing
        self.connection = Connection_wrapper(
            sqlite.connect(":memory:",
                           detect_types=sqlite.PARSE_DECLTYPES,
                           check_same_thread=False))
        self.cache = Stub_cache()
        cursor = self.connection.cursor()
        cursor.execute(Stub_object.sql_create_table())

        self.database = Database(self.connection, self.cache)
コード例 #4
0
    def setUp(self):
        # make an in-memory sqlite database to use during testing
        self.connection = Connection_wrapper(
            sqlite.connect(":memory:",
                           detect_types=sqlite.PARSE_DECLTYPES,
                           check_same_thread=False))
        self.cache = Stub_cache()
        cursor = self.connection.cursor()
        cursor.execute(Stub_object.sql_create_table())

        self.fake_files = {
        }  # map of fake filename (full path) to fake file contents
        self.database = Database(self.connection, self.cache)
        self.upgrader = Schema_upgrader(self.database,
                                        glob=self.glob,
                                        read_file=self.read_file)
コード例 #5
0
def main(args=None):
    nuke = False

    import cherrypy
    from config import Common

    cherrypy.config.update(Common.settings)
    desktop = False

    if args and "-d" in args:
        from config import Development
        settings = Development.settings
    elif args and "-l" in args:
        from config import Desktop
        settings = Desktop.settings
        desktop = True
    else:
        from config import Production
        settings = Production.settings

    cherrypy.config.update(settings)

    if args and ("-n" in args or "--nuke" in args):
        nuke = True
        print "This will nuke the contents of the database before initializing it with default data. Continue (y/n)? ",
        confirmation = sys.stdin.readline().strip()
        print

        if confirmation.lower()[0] != 'y':
            print "Exiting without touching the database."
            return

    print "Initializing the database with default data."
    host = cherrypy.config[u"luminotes.db_host"]  # TODO : this fails
    database = Database(
        host=host,
        ssl_mode=cherrypy.config[u"luminotes.db_ssl_mode"],
        data_dir=".",
    )
    #initializer = Initializer( database, host, cherrypy.config.configMap, desktop, nuke )
    initializer = Initializer(database, host, cherrypy.config, desktop, nuke)
コード例 #6
0
    def setUp(self):
        self.database = Database(
            Connection_wrapper(
                sqlite.connect(":memory:",
                               detect_types=sqlite.PARSE_DECLTYPES,
                               check_same_thread=False)),
            cache=Stub_cache(),
        )
        self.database.execute_script(file("model/schema.sqlite").read(),
                                     commit=True)

        self.username = u"mulder"
        self.password = u"trustno1"
        self.email_address = u"*****@*****.**"
        self.user = User.create(self.database.next_id(User), self.username,
                                self.password, self.email_address)
        self.database.save(self.user, commit=False)

        self.trash = Notebook.create(self.database.next_id(Notebook), u"trash")
        self.database.save(self.trash, commit=False)
        self.notebook = Notebook.create(self.database.next_id(Notebook),
                                        u"notebook",
                                        self.trash.object_id,
                                        user_id=self.user.object_id)
        self.database.save(self.notebook, commit=False)

        note_id = self.database.next_id(Note)
        self.note1 = Note.create(note_id,
                                 u"<h3>my title</h3>blah",
                                 notebook_id=self.notebook.object_id,
                                 startup=True,
                                 user_id=self.user.object_id)
        self.database.save(self.note1, commit=False)

        note_id = self.database.next_id(Note)
        self.note2 = Note.create(note_id,
                                 u"<h3>other title</h3>whee",
                                 notebook_id=self.notebook.object_id,
                                 user_id=self.user.object_id)
        self.database.save(self.note2, commit=False)
コード例 #7
0
def main(args):
    import cherrypy
    from config import Common

    cherrypy.config.update(Common.settings)

    if args and "-d" in args:
        from config import Development
        settings = Development.settings
    else:
        from config import Production
        settings = Production.settings

    cherrypy.config.update(settings)

    database = Database(
        host=cherrypy.config.configMap[u"global"].get(u"luminotes.db_host"),
        ssl_mode=cherrypy.config.configMap[u"global"].get(
            u"luminotes.db_ssl_mode"),
        data_dir=".",
    )

    class Stub_root(object):
        def __init__(self, database):
            self.database = database

    cherrypy.root = Stub_root(database)
    sessions = Session_storage()
    session_count = 0

    for session_filename in os.listdir(u"session/"):
        pickled_data = file(u"session/%s" % session_filename).read()
        (data, expiration_time) = pickle.loads(pickled_data)
        session_id = data[u"_id"]

        sessions.save(session_id, data, expiration_time)
        session_count += 1

    print "converted %d sessions" % session_count
コード例 #8
0
ファイル: luminotes.py プロジェクト: LimpingNinja/luminotes
def main(options):
    change_to_main_dir()

    cherrypy.config.update(Common.settings)
    if options.development:
        from config import Development
        settings = Development.settings
    elif options.desktop:
        from config import Desktop
        settings = Desktop.settings
    else:
        from config import Production
        settings = Production.settings

    cherrypy.config.update(settings)

    # Don't launch web browser if -w flag is set
    if options.no_webbrowser:
        launch_browser = False
    else:
        launch_browser = cherrypy.config[u"luminotes.launch_browser"]

    socket.setdefaulttimeout(INITIAL_SOCKET_TIMEOUT_SECONDS)
    port_filename = cherrypy.config[u"luminotes.port_file"]
    socket_port = cherrypy.config[u"server.socket_port"]
    existing_socket_port = port_filename and os.path.exists(
        port_filename) and file(port_filename).read() or socket_port
    server_url = u"http://localhost:%s/" % existing_socket_port
    server_present = True

    # if requested, attempt to shutdown an existing server and exit
    if options.kill:
        try:
            urllib.urlopen("%sshutdown" % server_url)
        except urllib.URLError:
            pass
        sys.exit(0)

    # check to see if the server is already running
    try:
        urllib.urlopen("%sping" % server_url)
    except urllib.URLError:
        server_present = False

    if server_present is True:
        print "Luminotes server is already running. aborting"

        if launch_browser is True:
            webbrowser.open_new(server_url)

        sys.exit(0)

    server_url = u"http://127.0.0.1:%s/" % socket_port

    # remove the existing log files, if any
    try:
        log_access_file = cherrypy.config[u"server.log_access_file"]
        if log_access_file:
            os.remove(log_access_file)
    except OSError:
        pass

    try:
        log_file = cherrypy.config[u"server.log_file"]
        if log_file:
            os.remove(log_file)
    except OSError:
        pass

    socket.setdefaulttimeout(SOCKET_TIMEOUT_SECONDS)

    database = Database(
        host=cherrypy.config[u"luminotes.db_host"],
        ssl_mode=cherrypy.config[u"luminotes.db_ssl_mode"],
    )

    # if necessary, upgrade the database schema to match this current version of the code
    schema_upgrader = Schema_upgrader(database)
    schema_upgrader.upgrade_schema(to_version=VERSION)

    cherrypy.lowercase_api = True
    root = Root(database, cherrypy.config)
    cherrypy.tree.mount(root, '/', config=settings)

    cherrypy.engine.start_with_callback(
        callback, (log_access_file, log_file, server_url, port_filename,
                   socket_port, launch_browser))
    cherrypy.engine.block()
コード例 #9
0
ファイル: dump_emails.py プロジェクト: LimpingNinja/luminotes
def main(args):
    database = Database(cache={})
    ranker = Dumper(database)
コード例 #10
0
    def setUp(self):
        # trick tested methods into using a fake SMTP server
        Stub_smtp.reset()
        smtplib.SMTP = Stub_smtp

        from controller.Root import Root
        cherrypy.lowercase_api = True
        self.database = Database(
            Connection_wrapper(
                sqlite.connect(":memory:",
                               detect_types=sqlite.PARSE_DECLTYPES,
                               check_same_thread=False)),
            cache=Stub_cache(),
        )
        self.database.execute_script(file("model/schema.sqlite").read(),
                                     commit=True)

        self.settings = {
            u"global": {
                u"server.environment":
                "production",
                u"session_filter.on":
                True,
                u"session_filter.storage_type":
                u"ram",
                u"encoding_filter.on":
                True,
                u"encoding_filter.encoding":
                "utf-8",
                u"decoding_filter.on":
                True,
                u"decoding_filter.encoding":
                "utf-8",
                u"server.log_to_screen":
                False,
                u"luminotes.http_url":
                u"http://luminotes.com",
                u"luminotes.https_url":
                u"https://luminotes.com",
                u"luminotes.http_proxy_ip":
                u"127.0.0.1",
                u"luminotes.https_proxy_ip":
                u"127.0.0.2",
                u"luminotes.support_email":
                "*****@*****.**",
                u"luminotes.payment_email":
                "*****@*****.**",
                u"luminotes.rate_plans": [
                    {
                        u"name":
                        u"super",
                        u"storage_quota_bytes":
                        1337 * 10,
                        u"notebook_collaboration":
                        False,
                        u"user_admin":
                        False,
                        u"included_users":
                        1,
                        u"fee":
                        1.99,
                        u"yearly_fee":
                        19.90,
                        u"button":
                        u"[subscribe here user %s!] button (modify=%s)",
                        u"yearly_button":
                        u"[yearly subscribe here user %s!] button (modify=%s)",
                    },
                    {
                        u"name":
                        "extra super",
                        u"storage_quota_bytes":
                        31337 * 1000,
                        u"notebook_collaboration":
                        True,
                        u"user_admin":
                        True,
                        u"included_users":
                        3,
                        u"fee":
                        9.00,
                        u"yearly_fee":
                        90.00,
                        u"button":
                        u"[or here user %s!] button (modify=%s)",
                        u"yearly_button":
                        u"[yearly or here user %s!] button (modify=%s)",
                    },
                ],
                "luminotes.download_products": [
                    {
                        "name": "local desktop extravaganza",
                        "designed_for": "individuals",
                        "storage_quota_bytes": None,
                        "included_users": 1,
                        "notebook_sharing": False,
                        "notebook_collaboration": False,
                        "user_admin": False,
                        "fee": "30.00",
                        "item_number": "5000",
                        "filename": "test.exe",
                        "button": u"",
                    },
                ],
            },
            u"/files/download": {
                u"stream_response": True,
                u"encoding_filter.on": False,
            },
            u"/files/download_product": {
                u"stream_response": True,
                u"encoding_filter.on": False,
            },
            u"/notebooks/export_csv": {
                u"stream_response": True,
                u"encoding_filter.on": False,
            },
            u"/files/progress": {
                u"stream_response": True,
            },
        }

        cherrypy.root = Root(self.database,
                             self.settings,
                             suppress_exceptions=True)
        cherrypy.config.update(self.settings)
        cherrypy.server.start(init_only=True, server_class=None)

        # since we only want to test the controller, use the stub view for all exposed methods
        import controller.Expose
        Stub_view.result = None
        controller.Expose.view_override = Stub_view
コード例 #11
0
ファイル: set_ranks.py プロジェクト: LimpingNinja/luminotes
def main( args ):
  database = Database()
  ranker = Ranker( database )