예제 #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
파일: page.py 프로젝트: Vichagserp/cimworks
	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)