Browse Source

auto commit

master
jfinn 3 years ago
parent
commit
188248c5e1
1 changed files with 29 additions and 1 deletions
  1. 29
    1
      wsps/tasks_loop.py

+ 29
- 1
wsps/tasks_loop.py View File

199
 class RldMan():
199
 class RldMan():
200
 	def __init__(self,*a,**kw):
200
 	def __init__(self,*a,**kw):
201
 		self.files = {}
201
 		self.files = {}
202
+		self.print_tb = 0
203
+		self.dflt_scope = {"globals":globals(),"locals":locals()}
204
+		self.dflt_scope2 = {"globals":copy.copy(globals()),"locals":copy.copy(locals())}
202
 
205
 
203
 		base_path = "/usr/games/repos/ign4/py_rld/djc/rdir1/"
206
 		base_path = "/usr/games/repos/ign4/py_rld/djc/rdir1/"
204
 
207
 
221
 				p("add files???",file)
224
 				p("add files???",file)
222
 	def add_file(self,file_name,fnx={}):
225
 	def add_file(self,file_name,fnx={}):
223
 		self.files[file_name] = {"ftxt":"",**fnx}
226
 		self.files[file_name] = {"ftxt":"",**fnx}
224
-	def rld_file(self,*a,**kw):pass
227
+	def rld_file(self,file_name,ret= {"errs":{},"all":{},"alle":{},},**kw):
228
+		if file_name in self.files:
229
+			rfile_obj = self.files[file_name]
230
+			st = os.stat(file_name)
231
+			st_tuple = (st.st_mtime,st.st_size)
232
+			if rfile_obj["ftxt"] != st_tuple:
233
+				rfile_obj["ftxt"] = st_tuple
234
+				try:
235
+					f = open(file_name,"r")
236
+					ftxt = f.read()
237
+					f.close()
238
+					exec(ftxt)
239
+
240
+				except Exception as e:
241
+					print("EXCEPT",eflag,e)
242
+					if self.print_tb:
243
+						traceback.print_tb(e.__traceback__,file=sys.stdout)
244
+				else:
245
+					pass
246
+					# print("ELSE")
247
+				finally:
248
+					# print("FINALLY")
249
+					pass
250
+				print(end="",flush=True)
251
+		return ret
252
+
225
 	def rld_files(self):
253
 	def rld_files(self):
226
 		# p()
254
 		# p()
227
 
255
 

Loading…
Cancel
Save