示例#1
0
    def read(self, do_execute=None):
        """
			Return the file content, if dynamic, execute it
		"""
        self.load_content()
        if do_execute and self.content.startswith('#!python'):
            from webnotes.model.code import execute
            self.content = execute(self.content)

        return self.content
示例#2
0
	def read(self, do_execute = None):
		"""
			Return the file content, if dynamic, execute it
		"""
		self.load_content()
		if do_execute and self.content.startswith('#!python'):
			from webnotes.model.code import execute
			self.content = execute(self.content)
			
		return self.content
示例#3
0
	def process_content(self, doc):
		"""
			Put in template and generate dynamic if starts with #!python
		"""
		template = self.get_template(doc.template)
		content = ''
		
		# eval content
		if doc.content and doc.content.startswith('#!python'):
			from webnotes.model.code import execute
			content = template % {'content': execute(doc.content).get('content')}
		else:
			content = template % {'content': doc.content or ''}				

		doc.__content = content
示例#4
0
	def run_script(self, script):
		try:
			self.connect(ac_name = self.ac_name)
			webnotes.conn = self.conn
			from webnotes.model import code
			self.conn.sql("start transaction")
			sc = code.execute(script)
			self.conn.sql("commit")
			print sc
			self.close()
		except Exception, e:
			print webnotes.utils.getTraceback()
			self.conn.sql("rollback")
			self.close()
			raise e
示例#5
0
    def process_content(self, doc):
        """
			Put in template and generate dynamic if starts with #!python
		"""
        template = self.get_template(doc.template)
        content = ''

        # eval content
        if doc.content and doc.content.startswith('#!python'):
            from webnotes.model.code import execute
            content = template % {
                'content': execute(doc.content).get('content')
            }
        else:
            content = template % {'content': doc.content or ''}

        doc.__content = content
示例#6
0
	
	ret = {}
	try:
		patch_list, ret = get_patch_list(modules, record_list, ret)
	except Exception, e:
		if e.args[0]==1146:
			return 'No table Patch'
		else:
			raise e
	
	for d in patch_list:
		try:
			if not webnotes.conn.in_transaction:
				webnotes.conn.sql("START TRANSACTION")
			#print 'Patch: ' + d[0]
			ret_msg = code.execute(d[1])
			webnotes.conn.sql("update tabPatch set status = 'Executed' where name = %s", d[0])
			webnotes.conn.sql("COMMIT")
		except Exception, e:
			ret_msg = e
		#finally: #Only works on python 2.5+
		ret[d[0]] = ret_msg

	return ret


# =============================================================================
# Get patch list
# =============================================================================
def get_patch_list(modules, record_list, ret):
	import webnotes
示例#7
0
	def test_execute(self):
		code.execute("import sys;sys.path.append('/home/')")
		assert ('/home/' in sys.path)