molhokwai 0 Newbie Poster

Looking for 'unqualified exec is not allowed in function' lead here...

This is a collaborative thing... so here's all of the code (some parts just description of eventual 'future' implementation) for a universal code parser (biiig name for a smaaaall thing, that is not working at all yet, and is limited to python)...

#!/usr/bin/python2.5
## acknowledgements: python, http://www.faqs.org/docs/diveintopython/regression_divein.html, ...

"""
	Moody documentation style...

	Philosophy
		Errors are part of the process, so we try... and catch...
		
	Vars
		caller: for eventual context stuff
		callee: what you think? ok... the path called...
		called: whaaaat you think? pffff... the item (method, variable...) we attempt to get, call, whatever...
		arguments: ...called item arguments
"""

import os

print 'callee, called, arguments...'

caller=sys.argv[0]
callee=sys.argv[1]
called=sys.argv[2]	
arguments=sys.argv[2]	


def try_call():
	for dirpath, dirnames, filenames in os.walk(callee, followlinks=True):
		filename_to_module_name = lambda f: os.path.splitext(f)[0]
		module_names = map(filename_to_module_name, filenames)

		os.chdir(dirpath)
		modules = map(__import__, moduleNames)
		for _m in modules:
			for key in _m.__dict__:
				## do we include the built ins somwhere in the future? goood question...
				if key != '__builtins__':
					try:
						## PROCESS:
						## 	check in db if call pattern saved, and if so execute
						## 		- if result not ok: save call data in db and analyze
						## 	else: check the type, if function, get arguments, infer/map/(all the suff) and execute, if variable bla bla...
						## 		- if result ok: save call data pattern
						## 	....
						## 	all of the above (eventually) for somewhen in the future... for now simple call...
						exec('res=%s.%s()' %  (_m, _m.__dict__[key]))
						print repr(res)
						
						if sys.argv[1]=='ok':
							## see process above
							print 'great...'

					except Exception, ex:
						print 'wooopsy... error...'
						print '---| call stuff: %s - %s ' % (key, repr(_m.__dict__[key]))
						print '---| ex : %s ' % repr(ex)

Ideas about implementing a different kind of operating system? http://code.google.com/p/sibos/
There's more, the new ideas might have outdated this, so...

Thanks...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.