本文整理汇总了Python中webnotes.utils.file_manager.get_file函数的典型用法代码示例。如果您正苦于以下问题:Python get_file函数的具体用法?Python get_file怎么用?Python get_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: import_att_data
def import_att_data(self):
filename = self.doc.file_list.split(',')
if not filename:
msgprint("Please attach a .CSV File.")
raise Exception
if filename[0].find('.csv') < 0:
raise Exception
if not filename and filename[0] and file[1]:
msgprint("Please Attach File. ")
raise Exception
from webnotes.utils import file_manager
fn, content = file_manager.get_file(filename[1])
# NOTE: Don't know why this condition exists
if not isinstance(content, basestring) and hasattr(content, 'tostring'):
content = content.tostring()
import webnotes.model.import_docs
im = webnotes.model.import_docs.CSVImport()
out = im.import_csv(content,self.doc.import_date_format, cint(self.doc.overwrite))
return out
开发者ID:hbkfabio,项目名称:erpnext,代码行数:25,代码来源:attendance_control_panel.py
示例2: attach_file
def attach_file(self, n):
"""attach a file from the `FileData` table"""
from webnotes.utils.file_manager import get_file
res = get_file(n)
if not res:
return
self.add_attachment(res[0], res[1])
开发者ID:appost,项目名称:wnframework,代码行数:8,代码来源:smtp.py
示例3: get_csv_file_data
def get_csv_file_data(self):
filename = self.doc.file_list.split(',')
if not filename:
msgprint("Please Attach File. ", raise_exception=1)
from webnotes.utils import file_manager
fn, content = file_manager.get_file(filename[1])
if not type(content) == str:
content = content.tostring()
return content
开发者ID:ravidey,项目名称:erpnext,代码行数:11,代码来源:stock_reconciliation.py
示例4: get_csv_file_data
def get_csv_file_data(self):
self.admin_msgprint("get_csv_file_data")
filename = self.doc.file_list.split(',')
if not filename and filename[0] and file[1]:
msgprint("Please Attach File. ")
raise Exception
from webnotes.utils import file_manager
fn, content = file_manager.get_file(filename[1])
if not type(content) == str:
content = content.tostring()
return content
开发者ID:ranjithtenz,项目名称:stable,代码行数:13,代码来源:Stock+Reconciliation.py
示例5: read_csv_content_from_attached_file
def read_csv_content_from_attached_file(doc):
if not doc.file_list:
msgprint("File not attached!")
raise Exception
try:
from webnotes.utils.file_manager import get_file
fid = doc.file_list.split(",")[1]
fname, fcontent = get_file(fid)
return read_csv_content(fcontent)
except Exception, e:
webnotes.msgprint("""Unable to open attached file. Please try again.""")
raise Exception
开发者ID:gowrav-vishwakarma,项目名称:wnframework,代码行数:13,代码来源:datautils.py
示例6: get_csv_data
def get_csv_data(self):
if not self.doc.file_list:
msgprint("File not attached!")
raise Exception
fid = self.doc.file_list.split(',')[1]
try:
from webnotes.utils import file_manager
fn, content = file_manager.get_file(fid)
except Exception, e:
webnotes.msgprint("Unable to open attached file. Please try again.")
raise e
开发者ID:smilekk,项目名称:erpnext,代码行数:13,代码来源:price_list.py
示例7: get_csv_file_data
def get_csv_file_data(self, submit = 1):
"""Get csv data"""
if submit:
filename = self.doc.file_list.split(',')
if not filename:
msgprint("Please Attach File. ", raise_exception=1)
from webnotes.utils import file_manager
fn, content = file_manager.get_file(filename[1])
else:
content = self.doc.diff_info
return content
开发者ID:smilekk,项目名称:erpnext,代码行数:13,代码来源:stock_reconciliation.py
示例8: get_csv_file_data
def get_csv_file_data(self):
"""Get csv data"""
filename = self.doc.file_list.split(',')
if not filename:
msgprint("Please Attach File. ", raise_exception=1)
from webnotes.utils import file_manager
fn, content = file_manager.get_file(filename[1])
# NOTE: Don't know why this condition exists
if not isinstance(content, basestring) and hasattr(content, 'tostring'):
content = content.tostring()
return content
开发者ID:antoxin,项目名称:erpnext,代码行数:14,代码来源:stock_reconciliation.py
示例9: read_csv_content_from_attached_file
def read_csv_content_from_attached_file(doc):
fileid = webnotes.conn.get_value("File Data", {"attached_to_doctype": doc.doctype,
"attached_to_name":doc.name}, "name")
if not fileid:
msgprint("File not attached!")
raise Exception
try:
from webnotes.utils.file_manager import get_file
fname, fcontent = get_file(fileid)
return read_csv_content(fcontent, webnotes.form_dict.get('ignore_encoding_errors'))
except Exception, e:
webnotes.msgprint("""Unable to open attached file. Please try again.""")
raise Exception
开发者ID:frank1638,项目名称:wnframework,代码行数:14,代码来源:datautils.py
示例10: get_csv_data
def get_csv_data(self):
if not self.doc.file_list:
msgprint("File not attached!")
raise Exception
fid = self.doc.file_list.split(',')[1]
from webnotes.utils import file_manager
fn, content = file_manager.get_file(fid)
if not type(content) == str:
content = content.tostring()
return content
开发者ID:Morphnus-IT-Solutions,项目名称:trimos,代码行数:14,代码来源:price_list.py
示例11: get_csv_data
def get_csv_data(self):
if not self.doc.file_list:
msgprint("File not attached!")
raise Exception
fid = self.doc.file_list.split(',')[1]
from webnotes.utils import file_manager
fn, content = file_manager.get_file(fid)
# NOTE: Don't know why this condition exists
if not isinstance(content, basestring) and hasattr(content, 'tostring'):
content = content.tostring()
return content
开发者ID:NorrWing,项目名称:erpnext,代码行数:15,代码来源:bulk_rename_tool.py
示例12: execute
def execute():
import webnotes
from webnotes.modules import reload_doc
reload_doc('stock', 'doctype', 'stock_reconciliation')
sr = webnotes.conn.sql("select name, file_list from `tabStock Reconciliation` where docstatus = 1")
for d in sr:
if d[1]:
filename = d[1].split(',')[1]
from webnotes.utils import file_manager
fn, content = file_manager.get_file(filename)
if not isinstance(content, basestring) and hasattr(content, 'tostring'):
content = content.tostring()
webnotes.conn.sql("update `tabStock Reconciliation` set diff_info = %s where name = %s and ifnull(diff_info, '') = ''", (content, d[0]))
开发者ID:AminfiBerlin,项目名称:erpnext,代码行数:17,代码来源:stock_reco_patch.py
示例13: attach
def attach(self, n):
"""
attach a file from the `FileData` table
"""
from webnotes.utils.file_manager import get_file
res = get_file(n)
if not res:
self.msg.attach('Sender tried to attach an unknown file id: ' + n)
from email.mime.audio import MIMEAudio
from email.mime.base import MIMEBase
from email.mime.image import MIMEImage
from email.mime.text import MIMEText
fname = res[0]
fcontent = res[1]
import mimetypes
ctype, encoding = mimetypes.guess_type(fname)
if ctype is None or encoding is not None:
# No guess could be made, or the file is encoded (compressed), so
# use a generic bag-of-bits type.
ctype = 'application/octet-stream'
maintype, subtype = ctype.split('/', 1)
if maintype == 'text':
# Note: we should handle calculating the charset
msg = MIMEText(fcontent, _subtype=subtype)
elif maintype == 'image':
msg = MIMEImage(fcontent, _subtype=subtype)
elif maintype == 'audio':
msg = MIMEAudio(fcontent, _subtype=subtype)
else:
msg = MIMEBase(maintype, subtype)
msg.set_payload(fcontent)
# Encode the payload using Base64
from email import encoders
encoders.encode_base64(msg)
# Set the filename parameter
msg.add_header('Content-Disposition', 'attachment', filename=fname)
self.msg.attach(msg)
开发者ID:cmrajan,项目名称:wnframework,代码行数:42,代码来源:email_lib.py
示例14: import_att_data
def import_att_data(self):
filename = self.doc.file_list.split(',')
if not filename:
msgprint("Please attach a .CSV File.")
raise Exception
if filename[0].find('.csv') < 0:
raise Exception
if not filename and filename[0] and file[1]:
msgprint("Please Attach File. ")
raise Exception
from webnotes.utils import file_manager
fn, content = file_manager.get_file(filename[1])
if not type(content) == str:
content = content.tostring()
import webnotes.model.import_docs
im = webnotes.model.import_docs.CSVImport()
out = im.import_csv(content,self.doc.import_date_format, cint(self.doc.overwrite))
return out
开发者ID:Morphnus-IT-Solutions,项目名称:trimos,代码行数:24,代码来源:attendance_control_panel.py
示例15: get_file
from webnotes.utils.file_manager import get_file
try:
fl = webnotes.conn.sql("select name from `tabFile Data` where module=%s", m)
except Exception, e:
if e.args[0]==1054: # no field called module
return
else:
raise e
# write the files
if fl:
folder = os.path.join(webnotes.defs.modules_path, m, 'files')
webnotes.create_folder(folder)
for f in fl:
file_det = get_file(f)
file = open(os.path.join(folder, file_det[0]), 'w+')
file.write(file_det[1])
file.close()
# ==============================================================================
# write module.info file with last updated timestamp
# ==============================================================================
def write_module_info(mod):
import webnotes.utils, os
file = open(os.path.join(get_module_path(mod), 'module.info'), 'w')
file.write(str({'update_date': webnotes.utils.now()}))
file.close()
开发者ID:ravidey,项目名称:wnframework,代码行数:31,代码来源:export_module.py
注:本文中的webnotes.utils.file_manager.get_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论