Example #1
0
def clear_web(site=None):
	import webnotes.webutils
	webnotes.connect(site=site)
	from website.doctype.website_sitemap_config.website_sitemap_config import build_website_sitemap_config
	build_website_sitemap_config()
	webnotes.webutils.clear_cache()
	webnotes.destroy()
Example #2
0
def latest(site=None, verbose=True):
	import webnotes.modules.patch_handler
	import webnotes.model.sync
	import webnotes.plugins
	from website.doctype.website_sitemap_config.website_sitemap_config import build_website_sitemap_config
	
	webnotes.connect(site=site)
	
	try:
		# run patches
		webnotes.local.patch_log_list = []
		webnotes.modules.patch_handler.run_all()
		if verbose:
			print "\n".join(webnotes.local.patch_log_list)
	
		# sync
		webnotes.model.sync.sync_all()
		
		# remove __init__.py from plugins
		webnotes.plugins.remove_init_files()
		
		# build website config if any changes in templates etc.
		build_website_sitemap_config()
		
	except webnotes.modules.patch_handler.PatchError, e:
		print "\n".join(webnotes.local.patch_log_list)
		raise
Example #3
0
def clear_web(site=None):
    import webnotes.webutils
    webnotes.connect(site=site)
    from website.doctype.website_sitemap_config.website_sitemap_config import build_website_sitemap_config
    build_website_sitemap_config()
    webnotes.webutils.clear_cache()
    webnotes.destroy()
Example #4
0
def latest(site=None, verbose=True):
    import webnotes.modules.patch_handler
    import webnotes.model.sync
    import webnotes.plugins
    from website.doctype.website_sitemap_config.website_sitemap_config import build_website_sitemap_config

    webnotes.connect(site=site)

    try:
        # run patches
        webnotes.local.patch_log_list = []
        webnotes.modules.patch_handler.run_all()
        if verbose:
            print "\n".join(webnotes.local.patch_log_list)

        # sync
        webnotes.model.sync.sync_all()

        # remove __init__.py from plugins
        webnotes.plugins.remove_init_files()

        # build website config if any changes in templates etc.
        build_website_sitemap_config()

    except webnotes.modules.patch_handler.PatchError, e:
        print "\n".join(webnotes.local.patch_log_list)
        raise
Example #5
0
def build_sitemap(site=None):
	from website.doctype.website_sitemap_config.website_sitemap_config import build_website_sitemap_config
	webnotes.connect(site=site)
	build_website_sitemap_config()
	webnotes.destroy()
Example #6
0
def build_sitemap(site=None):
    from website.doctype.website_sitemap_config.website_sitemap_config import build_website_sitemap_config
    webnotes.connect(site=site)
    build_website_sitemap_config()
    webnotes.destroy()
Example #7
0
class Installer:
    def __init__(self,
                 root_login,
                 root_password=None,
                 db_name=None,
                 site=None,
                 site_config=None):
        make_conf(db_name, site=site, site_config=site_config)
        self.site = site

        if isinstance(root_password, list):
            root_password = root_password[0]

        # print root_password
        self.make_connection(root_login, root_password)

        webnotes.local.conn = self.conn
        webnotes.local.session = webnotes._dict({'user': '******'})

        self.dbman = DbManager(self.conn)

    def make_connection(self, root_login, root_password):
        if root_login:
            if not root_password:
                root_password = webnotes.conf.get("root_password") or None

            if not root_password:
                root_password = getpass.getpass("MySQL root password: "******"Database %s already exists" % (db_name, ))

        # create user and db
        self.dbman.create_user(db_name, webnotes.conf.db_password)

        if verbose: print "Created user %s" % db_name

        # create a database
        self.dbman.create_database(db_name)
        if verbose: print "Created database %s" % db_name

        # grant privileges to user
        self.dbman.grant_all_privileges(db_name, db_name)
        if verbose:
            print "Granted privileges to user %s and database %s" % (db_name,
                                                                     db_name)

        # flush user privileges
        self.dbman.flush_privileges()

        # close root connection
        self.conn.close()

        webnotes.connect(db_name=db_name, site=self.site)
        self.dbman = DbManager(webnotes.conn)

        # import in db_name
        if verbose: print "Starting database import..."

        # get the path of the sql file to import
        if not source_sql:
            source_sql = os.path.join(os.path.dirname(webnotes.__file__), "..",
                                      'conf', 'Framework.sql')

        self.dbman.restore_database(db_name, source_sql, db_name,
                                    webnotes.conf.db_password)
        if verbose: print "Imported from database %s" % source_sql

        self.create_auth_table()

        # fresh app
        if 'Framework.sql' in source_sql:
            if verbose: print "Installing app..."
            self.install_app(verbose=verbose)

        # update admin password
        self.update_admin_password(admin_password)

        # create public folder
        from webnotes.install_lib import setup_public_folder
        setup_public_folder.make(site=self.site)

        if not self.site:
            from webnotes.build import bundle
            bundle(False)

        return db_name

    def install_app(self, verbose=False):
        sync_for("lib", force=True, sync_everything=True, verbose=verbose)
        self.import_core_docs()

        try:
            from startup import install
        except ImportError, e:
            install = None

        if os.path.exists("app"):
            sync_for("app", force=True, sync_everything=True, verbose=verbose)

        if os.path.exists(os.path.join("app", "startup", "install_fixtures")):
            install_fixtures()

        # build website sitemap
        from website.doctype.website_sitemap_config.website_sitemap_config import build_website_sitemap_config
        build_website_sitemap_config()

        if verbose: print "Completing App Import..."
        install and install.post_import()
        if verbose: print "Updating patches..."
        self.set_all_patches_as_completed()
        self.assign_all_role_to_administrator()