• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.get_base_path函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中webnotes.utils.get_base_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_base_path函数的具体用法?Python get_base_path怎么用?Python get_base_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_base_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: backup_to_dropbox

def backup_to_dropbox():
	from dropbox import client, session
	from conf import dropbox_access_key, dropbox_secret_key
	from webnotes.utils.backups import new_backup
	if not webnotes.conn:
		webnotes.connect()

	sess = session.DropboxSession(dropbox_access_key, dropbox_secret_key, "app_folder")

	sess.set_token(webnotes.conn.get_value("Backup Manager", None, "dropbox_access_key"),
		webnotes.conn.get_value("Backup Manager", None, "dropbox_access_secret"))
	
	dropbox_client = client.DropboxClient(sess)

	# upload database
	backup = new_backup()
	filename = os.path.join(get_base_path(), "public", "backups", 
		os.path.basename(backup.backup_path_db))
	upload_file_to_dropbox(filename, "database", dropbox_client)

	response = dropbox_client.metadata("/files")
	# upload files to files folder
	path = os.path.join(get_base_path(), "public", "files")
	for filename in os.listdir(path):
		found = False
		filepath = os.path.join(path, filename)
		for file_metadata in response["contents"]:
 			if os.path.basename(filepath) == os.path.basename(file_metadata["path"]) and os.stat(filepath).st_size == int(file_metadata["bytes"]):
				found = True
				break
		if not found:
			upload_file_to_dropbox(filepath, "files", dropbox_client)
开发者ID:PhamThoTam,项目名称:erpnext,代码行数:32,代码来源:backup_dropbox.py


示例2: on_update

 def on_update(self):
     webnotes.errprint("hiii")
     if not (os.path.exists(os.path.join(get_base_path(), "sites"))):
         self.make_primary_sites_settings()
     if not (os.path.exists(os.path.join(get_base_path(), "sites", self.doc.site_name))):
         self.create_new_site()
     self.update_global_defaults()
     webnotes.msgprint("Updated")
开发者ID:saurabh6790,项目名称:omnitech-lib,代码行数:8,代码来源:site_details.py


示例3: on_update

	def on_update(self):
		# webnotes.errprint("hiii")
		# return "in update"
		if not (os.path.exists(os.path.join(get_base_path(), "sites"))):
			self.make_primary_sites_settings()
			
		if not (os.path.exists(os.path.join(get_base_path(), "sites", self.doc.site_name))):
			# webnotes.errprint("saurabh.p")
			self.create_new_site()
开发者ID:saurabh6790,项目名称:omn-lib,代码行数:9,代码来源:site_details.py


示例4: update_db_name_pwd

	def update_db_name_pwd(self):
		os.path.join(get_base_path(), "sites", self.doc.site_name, 'site_config.json')
		with open (os.path.join(get_base_path(), "sites", self.doc.site_name, 'site_config.json'), 'r') as site_config:
			lines = site_config.readlines()

		db_name = lines[1].split(':')[1].replace('"','')[:-3]
		db_pwd = lines[2].split(':')[1].replace('"','')[:-1]
		webnotes.conn.sql("update `tabSite Details` set database_name = LTRIM('%s'), database_password = LTRIM('%s') where name = '%s' "%(db_name, db_pwd, self.doc.name))
		webnotes.conn.sql("commit")
开发者ID:saurabh6790,项目名称:omn-lib,代码行数:9,代码来源:site_details.py


示例5: execute

def execute():
	# remove pyc files
	utils_pyc = os.path.join(get_base_path(), "app", "selling", "utils.pyc")
	if os.path.exists(utils_pyc):
		os.remove(utils_pyc)
	
	old_path = os.path.join(get_base_path(), "app", "website")
	if os.path.exists(old_path):
		shutil.rmtree(old_path)
开发者ID:Anirudh887,项目名称:erpnext,代码行数:9,代码来源:p03_move_website_to_framework.py


示例6: create_new_site

	def create_new_site(self):

		root_password = webnotes.conn.get_value("Global Defaults", None, "mysql_root_password")

		exec_in_shell("""{path}/lib/wnf.py --install {dbname} --root-password {root_password} --site {name}
			""".format(path=get_base_path(), dbname=self.doc.site_name.replace('.', '_'), root_password=root_password, name=self.doc.site_name))

		self.add_to_hosts()

		exec_in_shell("{path}/lib/wnf.py --build".format(path=get_base_path()))

		self.update_db_name_pwd()
开发者ID:saurabh6790,项目名称:omn-lib,代码行数:12,代码来源:site_details.py


示例7: backup_to_gdrive

def backup_to_gdrive():
	from webnotes.utils.backups import new_backup
	if not webnotes.conn:
		webnotes.connect()
	get_gdrive_flow()
	credentials_json = webnotes.conn.get_value("Backup Manager", None, "gdrive_credentials")
	credentials = oauth2client.client.Credentials.new_from_json(credentials_json)
	http = httplib2.Http()
	http = credentials.authorize(http)
	drive_service = build('drive', 'v2', http=http)

	# upload database
	backup = new_backup()
	path = os.path.join(get_base_path(), "public", "backups")
	filename = os.path.join(path, os.path.basename(backup.backup_path_db))
	
	# upload files to database folder
	upload_files(filename, 'application/x-gzip', drive_service, 
		webnotes.conn.get_value("Backup Manager", None, "database_folder_id"))
	
	# upload files to files folder
	did_not_upload = []
	error_log = []
	
	files_folder_id = webnotes.conn.get_value("Backup Manager", None, "files_folder_id")
	
	webnotes.conn.close()
	path = os.path.join(get_base_path(), "public", "files")
	for filename in os.listdir(path):
		found = False
		filepath = os.path.join(path, filename)
		ext = filename.split('.')[-1]
		size = os.path.getsize(filepath)
		if ext == 'gz' or ext == 'gzip':
			mimetype = 'application/x-gzip'
		else:
			mimetype = mimetypes.types_map.get("." + ext) or "application/octet-stream"
		
		#Compare Local File with Server File
		param = {}
	  	children = drive_service.children().list(folderId=files_folder_id, **param).execute()
	  	for child in children.get('items', []):
			file = drive_service.files().get(fileId=child['id']).execute()
			if filename == file['title'] and size == int(file['fileSize']):
				found = True
				break
		if not found:
			try:
				upload_files(filepath, mimetype, drive_service, files_folder_id)
			except Exception, e:
				did_not_upload.append(filename)
				error_log.append(cstr(e))
开发者ID:gplayman,项目名称:erpnext,代码行数:52,代码来源:backup_googledrive.py


示例8: initiate_tenant_ctreation

	def initiate_tenant_ctreation(self, root_password, site_name, is_parent=False):

		exec_in_shell("""{path}/lib/wnf.py --install {dbname} --root-password {root_password} --site {name}
			""".format(path=get_base_path(), dbname=site_name[:16].replace('.', '_'), root_password=root_password, name=site_name))

		self.add_to_hosts(site_name)

		exec_in_shell("{path}/lib/wnf.py --build".format(path=get_base_path()))

		if is_parent:
			self.update_db_name_pwd()
		else:
			self.update_child_details(site_name)
开发者ID:saurabh6790,项目名称:OFF-RISLIB,代码行数:13,代码来源:site_details.py


示例9: backup_to_dropbox

def backup_to_dropbox():
    from dropbox import client, session
    from conf import dropbox_access_key, dropbox_secret_key
    from webnotes.utils.backups import new_backup

    if not webnotes.conn:
        webnotes.connect()

    sess = session.DropboxSession(dropbox_access_key, dropbox_secret_key, "app_folder")

    sess.set_token(
        webnotes.conn.get_value("Backup Manager", None, "dropbox_access_key"),
        webnotes.conn.get_value("Backup Manager", None, "dropbox_access_secret"),
    )

    dropbox_client = client.DropboxClient(sess)

    # upload database
    backup = new_backup()
    filename = os.path.join(get_base_path(), "public", "backups", os.path.basename(backup.backup_path_db))
    upload_file_to_dropbox(filename, "/database", dropbox_client)

    webnotes.conn.close()
    response = dropbox_client.metadata("/files")

    # upload files to files folder
    did_not_upload = []
    error_log = []
    path = os.path.join(get_base_path(), "public", "files")
    for filename in os.listdir(path):
        filename = cstr(filename)
        if filename in ignore_list:
            continue

        found = False
        filepath = os.path.join(path, filename)
        for file_metadata in response["contents"]:
            if os.path.basename(filepath) == os.path.basename(file_metadata["path"]) and os.stat(
                filepath
            ).st_size == int(file_metadata["bytes"]):
                found = True
                break
        if not found:
            try:
                upload_file_to_dropbox(filepath, "/files", dropbox_client)
            except Exception:
                did_not_upload.append(filename)
                error_log.append(webnotes.getTraceback())

    webnotes.connect()
    return did_not_upload, list(set(error_log))
开发者ID:Jdfkat,项目名称:erpnext,代码行数:51,代码来源:backup_dropbox.py


示例10: create_site

def create_site():
	from webnotes.model.code import get_obj
	webnotes.errprint('test')
	sites = webnotes.conn.sql("""select name from `tabSite Details` where flag = 'False' """,as_list=1)
	# webnotes.errprint(sites)
	for site in sites:

		"""For Primary site creation, checks site path exist or not"""
		if not (os.path.exists(os.path.join(get_base_path(), "sites"))):
			get_obj('Site Details', site[0]).make_primary_sites_settings()

		"""For secondary sites"""
		if not (os.path.exists(os.path.join(get_base_path(), "sites", site[0]))):
			get_obj('Site Details', site[0]).create_new_site()
			# webnotes.conn.sql("""update `tabSite Details` set flag = 'True' where name = '%s' """%(site[0]),as_list=1)	
开发者ID:saurabh6790,项目名称:OFF-RISLIB,代码行数:15,代码来源:site_details.py


示例11: clear_pyc_files

def clear_pyc_files():
	from webnotes.utils import get_base_path
	for path, folders, files in os.walk(get_base_path()):
		if 'locale' in folders: folders.remove('locale')
		for f in files:
			if f.decode("utf-8").endswith(".pyc"):
				os.remove(os.path.join(path, f))
开发者ID:Halfnhav,项目名称:wnframework,代码行数:7,代码来源:build.py


示例12: get_uuid

def get_uuid():
	import xml.etree.ElementTree as ET
	tree = ET.parse('{path}/hardware.xml'.format(path=os.path.join(get_base_path(), "public", "files")))
	root = tree.getroot()
	for child in root.iter('setting'):
		if child.attrib['id'] == 'uuid':
			return child.attrib['value']
开发者ID:saurabh6790,项目名称:OFF-RISAPP,代码行数:7,代码来源:setup_wizard.py


示例13: setup_account

def setup_account(args=None):
	# if webnotes.conn.sql("select name from tabCompany"):
	# 	webnotes.throw(_("Setup Already Complete!!"))
		
	if not args:
		args = webnotes.local.form_dict
	if isinstance(args, basestring):
		args = json.loads(args)
	args = webnotes._dict(args)
	
	update_profile_name(args)
	create_fiscal_year_and_company(args)
	set_defaults(args)
	create_territories()
	# create_price_lists(args)
	create_feed_and_todo()
	import_core_docs()
	# create_email_digest()
	# create_letter_head(args)
	# create_taxes(args)
	# create_items(args)
	# create_customers(args)
	# create_suppliers(args)
	webnotes.conn.set_value('Control Panel', None, 'home_page', 'desktop')

	webnotes.clear_cache()
	webnotes.conn.commit()
	
	# suppress msgprints
	webnotes.local.message_log = []
	exec_in_shell("""cp -r {path}/lib/public/datatable {path}/public/files 
		""".format(path=get_base_path()))
	webnotes.conn.sql("CREATE TABLE ack(ENCOUNTER_ID varchar(20),ACK varchar(20))")
	webnotes.conn.sql("commit()")
	return "okay"
开发者ID:saurabh6790,项目名称:OFF-RISAPP,代码行数:35,代码来源:setup_wizard-late.py


示例14: store_stock_reco_json

def store_stock_reco_json():
	import os
	import json
	from webnotes.utils.datautils import read_csv_content
	from webnotes.utils import get_base_path
	files_path = os.path.join(get_base_path(), "public", "files")
	
	list_of_files = os.listdir(files_path)
	replaced_list_of_files = [f.replace("-", "") for f in list_of_files]
	
	for reco, file_list in webnotes.conn.sql("""select name, file_list 
			from `tabStock Reconciliation`"""):
		if file_list:
			file_list = file_list.split("\n")
			stock_reco_file = file_list[0].split(",")[1]
			stock_reco_file_path = os.path.join(files_path, stock_reco_file)
			if not os.path.exists(stock_reco_file_path):
				if stock_reco_file in replaced_list_of_files:
					stock_reco_file_path = os.path.join(files_path,
						list_of_files[replaced_list_of_files.index(stock_reco_file)])
				else:
					stock_reco_file_path = ""
			
			if stock_reco_file_path:
				with open(stock_reco_file_path, "r") as open_reco_file:
					content = open_reco_file.read()
					try:
						content = read_csv_content(content)
						reconciliation_json = json.dumps(content, separators=(',', ': '))
						webnotes.conn.sql("""update `tabStock Reconciliation`
							set reconciliation_json=%s where name=%s""", 
							(reconciliation_json, reco))
					except Exception:
						# if not a valid CSV file, do nothing
						pass
开发者ID:BillTheBest,项目名称:erpnext,代码行数:35,代码来源:stock_reconciliation_patch.py


示例15: generate_barcode

 def generate_barcode(self):
     webnotes.errprint([self.doc.naming_series])
     # self.doc.patient_online_id=self.doc.name
     # from barcode.writer import ImageWriter
     # ean = barcode.get('code39','123322ABS232')
     # webnotes.errprint(ean)
     # path = os.path.join(get_base_path(), "public", "barcode_img")+"/"+self.doc.name
     # fullname = ean.save(path)
     # barcode_img = '<html>\
     #         <table style="width: 100%; table-layout: fixed;">\
     #                 <tr>\
     #                         <td style="width:510px">\
     #                                 <img src="'"/barcode_img/"+self.doc.name+".png"'" width="200px">\
     #                         </td>\
     #                 </tr>\
     #         </table>\
     # </html>'
     #s="23232ASA343222"
     s=self.doc.name
     import barcode
     from barcode.writer import ImageWriter
     ean = barcode.get('code39', s, writer=ImageWriter())
     path = os.path.join(get_base_path(), "public", "barcode_img")+"/"+s
     filename = ean.save(path)
     barcode_img = '<html>\
                     <table style="width: 100%; table-layout: fixed;">\
                         <tr>\
                             <td style="width:510px">\
                                 <img src="'"../barcode_img/"+s+".png"'" width="200px">\
                             </td>\
                         </tr>\
                     </table>\
                 </html>'
     self.doc.barcode_image = barcode_img
     self.doc.save()
开发者ID:saurabh6790,项目名称:alert-med-app,代码行数:35,代码来源:patient_register.py


示例16: update_child_details

	def update_child_details(self, sub_tenant_url):
		with open (get_base_path()+'/sites/'+sub_tenant_url+'/site_config.json', 'r') as site_config:
			lines = site_config.readlines()

		db_name = lines[1].split(':')[1].replace('"','')[:-3]
		db_pwd = lines[2].split(':')[1].replace('"','')[:-1]
		webnotes.conn.sql("update `tabSub Tenant Details` set db = LTRIM('%s'), pwd = LTRIM('%s') where sub_tenant_url = '%s' "%(db_name, db_pwd, sub_tenant_url), debug=1)
		webnotes.conn.sql("commit")
开发者ID:saurabh6790,项目名称:OFF-RISLIB,代码行数:8,代码来源:site_details.py


示例17: add_to_hosts

	def add_to_hosts(self):
		webnotes.errprint("host")
		with open('/etc/hosts', 'rt') as f:
			s = f.read() + '\n' + '127.0.0.1\t\t\t %s \n'%self.doc.site_name
			with open('hosts', 'wt') as outf:
				outf.write(s)

		os.system('echo gangadhar | sudo -S mv {path}/hosts /etc/hosts'.format(path=get_base_path()))
开发者ID:PriyaShitole,项目名称:MedViger-lib,代码行数:8,代码来源:site_details.py


示例18: execute

def execute():
	import shutil
	from webnotes.utils import get_base_path
	
	for dt in ("item_price", "price_list"):
		path = os.path.join(get_base_path(), "app", "setup", "doctype", dt)
		if os.path.exists(path):
			shutil.rmtree(path)
开发者ID:rohitw1991,项目名称:innoworth-app,代码行数:8,代码来源:p08_cleanup_after_item_price_module_change.py


示例19: _sub

	def _sub(match):
		require_path = re.search('["\'][^"\']*["\']', match.group(0)).group(0)[1:-1]
		fpath = os.path.join(get_base_path(), require_path)
		if os.path.exists(fpath):
			with open(fpath, 'r') as f:
				return '\n' + unicode(f.read(), "utf-8") + '\n'
		else:
			return 'wn.require("%s")' % require_path
开发者ID:ricardomomm,项目名称:wnframework,代码行数:8,代码来源:doctype.py


示例20: execute

def execute():
	from webnotes.utils import get_base_path
	import shutil
	import os
	
	utils_path = os.path.join(get_base_path(), "app", "accounts", "utils")
	if os.path.exists(utils_path):
		shutil.rmtree(utils_path)
开发者ID:BANSALJEE,项目名称:erpnext,代码行数:8,代码来源:remove_account_utils_folder.py



注:本文中的webnotes.utils.get_base_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.get_defaults函数代码示例发布时间:2022-05-26
下一篇:
Python utils.formatdate函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap