rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
print("=============Materials creation summary:=================") print("Created ",n," materials,") print("Loaded ",len(tx)-tex_load_fails," textures.") if tex_load_fails>0: print("WARNING! ",tex_load_fails," of ",len(tx)," textures aren't loaded, possibly wrong file name(s)!")
def create_materials(groups,materials,textures,orbiterpath): #counting material/texture combinations print("Creating materials") matpairset=set() matpair=[] # [(mat,tex),[mgroups...]] Unique mat+tex and corresponding groups for n in range(len(groups)): l=(groups[n][1],groups[n][2]) #print(l) if l not in matpa...
def load_msh(filename,orbiterpath,convert_coords):
def load_msh(filename,orbiterpath,convert_coords,show_single_sided):
def load_msh(filename,orbiterpath,convert_coords): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of groups from header n...
print("Reading groups:")
print("------------------------Reading groups:----------------------------")
def load_msh(filename,orbiterpath,convert_coords): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of groups from header n...
n_mat=int(v1[1])
n_mat=int(v1[1].rstrip(";"))
def load_msh(filename,orbiterpath,convert_coords): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of groups from header n...
n_tex=int(v1[1])
n_tex=int(v1[1].rstrip(";"))
def load_msh(filename,orbiterpath,convert_coords): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of groups from header n...
nt=int(v1[2])
nt=int(v1[2].rstrip(";"))
def load_msh(filename,orbiterpath,convert_coords): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of groups from header n...
if convert_coords:
if convert_uvs:
def load_msh(filename,orbiterpath,convert_coords): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of groups from header n...
obj=create_mesh(label,vtx,tri,norm,uv) if n_mat!=0: mat.append(n_mat) if n_tex!=0: tex.append(n_tex)
obj=create_mesh(label,vtx,tri,norm,uv,show_single_sided)
def load_msh(filename,orbiterpath,convert_coords): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of groups from header n...
print("Materials in groups:",mat) print("Textures in groups:",tex) file.close()
file.close()
def load_msh(filename,orbiterpath,convert_coords): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of groups from header n...
show_single_sided= BoolProperty(name="Show single-sided", description="Disables 'Double Sided' checkbox, some models look better if enabled", default=True)
def load_msh(filename,orbiterpath,convert_coords): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of groups from header n...
load_msh(self.filepath,self.orbiterpath,self.convert_coords)
load_msh(self.filepath,self.orbiterpath,self.convert_coords,self.show_single_sided)
def execute(self,context): print("execute") load_msh(self.filepath,self.orbiterpath,self.convert_coords) return{"FINISHED"}
file.write("MATERIAL {}\n".format(mtrls[mat.name]))
file.write("MATERIAL {}\n".format(mtrls[mat.name]+1))
def export_msh(filepath,convert_coords): nonormal=False if os.path.splitext(filepath)[1]=="": filepath=filepath+".msh" file=open(filepath,"w") file.write("MSHX1\n") ngroups=0 for obj in bpy.context.selected_objects: if obj.type=='MESH': ngroups=ngroups+1 file.write("GROUPS {}\n".format(ngroups)) mtrls={} txtrs={} ...
file.write("TEXTURE {}\n".format(txtrs[tex.name]))
file.write("TEXTURE {}\n".format(txtrs[tex.name]+1))
def export_msh(filepath,convert_coords): nonormal=False if os.path.splitext(filepath)[1]=="": filepath=filepath+".msh" file=open(filepath,"w") file.write("MSHX1\n") ngroups=0 for obj in bpy.context.selected_objects: if obj.type=='MESH': ngroups=ngroups+1 file.write("GROUPS {}\n".format(ngroups)) mtrls={} txtrs={} ...
file.write("TEXTURE 0\n") else: file.write("TEXTURE 0\n") else: file.write("MATERIAL 0\n")
def export_msh(filepath,convert_coords): nonormal=False if os.path.splitext(filepath)[1]=="": filepath=filepath+".msh" file=open(filepath,"w") file.write("MSHX1\n") ngroups=0 for obj in bpy.context.selected_objects: if obj.type=='MESH': ngroups=ngroups+1 file.write("GROUPS {}\n".format(ngroups)) mtrls={} txtrs={} ...
def create_mesh(name,verts,faces,norm,uv,show_single_sided):
def create_mesh(name,verts,faces,norm,uv,param_vector):
def create_mesh(name,verts,faces,norm,uv,show_single_sided): '''Function that creates mesh from loaded data''' me = bpy.data.meshes.new(name+"Mesh") ob = bpy.data.objects.new(name, me) ob.location =(0,0,0) #origin # Link object to scene bpy.context.scene.objects.link(ob) if show_single_sided: me.show_double_sided=Fals...
def create_materials(groups,materials,textures,orbiterpath): print("Creating materials")
def join_case_insensitive(fpath,f): ''' helper for find_texture_path() Trying to join filepath case-insensitive in Posix systems Returns: joined path if it finds f "" if it finds nothing ''' ld=os.listdir(fpath) if f in set(ld): print("Original name is good: ",f) return os.path.join(fpath,f) else: for f1 in ld: if ...
def create_mesh(name,verts,faces,norm,uv,show_single_sided): '''Function that creates mesh from loaded data''' me = bpy.data.meshes.new(name+"Mesh") ob = bpy.data.objects.new(name, me) ob.location =(0,0,0) #origin # Link object to scene bpy.context.scene.objects.link(ob) if show_single_sided: me.show_double_sided=Fals...
print(matpair)
if VERBOSE_OUT: print(matpair)
def create_materials(groups,materials,textures,orbiterpath): #counting material/texture combinations print("Creating materials") matpairset=set() matpair=[] # [(mat,tex),[mgroups...]] Unique mat+tex and corresponding groups for n in range(len(groups)): l=(groups[n][1],groups[n][2]) #print(l) if l not in matpa...
v=ntpath.split(textures[n][0]) print(v); fpath=os.path.join(orbiterpath,"Textures") for i in v: fpath=os.path.join(fpath,i) print (fpath)
fpath=find_texture_path(orbiterpath,textures[n][0]) if fpath=="": tex_load_fails=tex_load_fails+1 continue
def create_materials(groups,materials,textures,orbiterpath): #counting material/texture combinations print("Creating materials") matpairset=set() matpair=[] # [(mat,tex),[mgroups...]] Unique mat+tex and corresponding groups for n in range(len(groups)): l=(groups[n][1],groups[n][2]) #print(l) if l not in matpa...
print("!!!!!Can not load image: ",fpath)
print("Can not load image, file is possibly corrupted : ",fpath)
def create_materials(groups,materials,textures,orbiterpath): #counting material/texture combinations print("Creating materials") matpairset=set() matpair=[] # [(mat,tex),[mgroups...]] Unique mat+tex and corresponding groups for n in range(len(groups)): l=(groups[n][1],groups[n][2]) #print(l) if l not in matpa...
print("idx_mat=",idx_mat) print("mat_name=",materials[idx_mat][0]) print("diff=",materials[idx_mat][1][:3]) print("tex=",textures[idx_tex][1],"idx=",idx_tex)
if VERBOSE_OUT: print("idx_mat=",idx_mat) print("mat_name=",materials[idx_mat][0]) print("diff=",materials[idx_mat][1][:3]) if len(textures)>0: print("tex=",textures[idx_tex][1],"idx=",idx_tex)
def create_materials(groups,materials,textures,orbiterpath): #counting material/texture combinations print("Creating materials") matpairset=set() matpair=[] # [(mat,tex),[mgroups...]] Unique mat+tex and corresponding groups for n in range(len(groups)): l=(groups[n][1],groups[n][2]) #print(l) if l not in matpa...
matt[n].specular_hardness=materials[idx_mat][3][4]
if raise_small_hardness and (materials[idx_mat][3][4]<default_hardeness): matt[n].specular_hardness=default_hardeness else: matt[n].specular_hardness=materials[idx_mat][3][4]
def create_materials(groups,materials,textures,orbiterpath): #counting material/texture combinations print("Creating materials") matpairset=set() matpair=[] # [(mat,tex),[mgroups...]] Unique mat+tex and corresponding groups for n in range(len(groups)): l=(groups[n][1],groups[n][2]) #print(l) if l not in matpa...
def load_msh(filename,orbiterpath,convert_coords,show_single_sided):
def load_msh(filename,param_vector):
def load_msh(filename,orbiterpath,convert_coords,show_single_sided): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of gr...
if VERBOSE_OUT: print ("Group No:",n_grp," verts=",nv," tris=",nt)
def load_msh(filename,orbiterpath,convert_coords,show_single_sided): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of gr...
obj=create_mesh(label,vtx,tri,norm,uv,show_single_sided)
obj=create_mesh(label,vtx,tri,norm,uv,param_vector)
def load_msh(filename,orbiterpath,convert_coords,show_single_sided): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of gr...
print("Reading material component,n=",n," comp=",v1)
if VERBOSE_OUT: print("Reading material component,n=",n," comp=",v1)
def load_msh(filename,orbiterpath,convert_coords,show_single_sided): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of gr...
textures.append([file.readline().strip(),"ORBTexture"+str(i)])
textures.append([file.readline().split()[0],"ORBTexture"+str(i)])
def load_msh(filename,orbiterpath,convert_coords,show_single_sided): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of gr...
print("\nData:\nGroups:") print(groups,"\nReal No=",len(groups)) print("Materials:",materials) print("Textures:",textures)
if VERBOSE_OUT: print("\nData:\n-----------Groups:------------\n",groups) print("-----------------Materials:------------\n",materials) print("------------------Textures:------------\n",textures) print("\nReal groups No=",len(groups))
def load_msh(filename,orbiterpath,convert_coords,show_single_sided): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of gr...
create_materials(groups,materials,textures,orbiterpath)
create_materials(groups,materials,textures,orbiterpath,param_vector)
def load_msh(filename,orbiterpath,convert_coords,show_single_sided): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of gr...
orbiterpath= StringProperty(name="Orbiter Path", description="Orbiter spacesim path", maxlen=1024, default=ORBITER_PATH_DEFAULT, subtype="DIR_PATH")
def load_msh(filename,orbiterpath,convert_coords,show_single_sided): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of gr...
load_msh(self.filepath,self.orbiterpath,self.convert_coords,self.show_single_sided)
param_vector=[self.convert_coords,self.show_single_sided,self.raise_small_hardness,self.default_hardness] load_msh(self.filepath,param_vector)
def execute(self,context): print("execute") load_msh(self.filepath,self.orbiterpath,self.convert_coords,self.show_single_sided) return{"FINISHED"}
if len(v2)>3:
if len(v2)>5:
def load_msh(filename,orbiterpath,convert_coords): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of groups from header n...
if len(v2)>6:
if len(v2)==8:
def load_msh(filename,orbiterpath,convert_coords): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of groups from header n...
matt.append(bpy.data.materials.new(materials[idx_mat][0])) matt[n].diffuse_color=materials[idx_mat][1][:3] matt[n].alpha=materials[idx_mat][1][3] if materials[idx_mat][1][3]<1.0: matt[n].use_transparency=True matt[n].specular_color=materials[idx_mat][3][:3] matt[n].specular_alpha=materials[idx_mat][3][3]
if idx_mat>=0: matt.append(bpy.data.materials.new(materials[idx_mat][0])) matt[n].diffuse_color=materials[idx_mat][1][:3] matt[n].alpha=materials[idx_mat][1][3] if materials[idx_mat][1][3]<1.0: matt[n].use_transparency=True matt[n].specular_color=materials[idx_mat][3][:3] matt[n].specular_alpha=materials[idx_mat][3][...
def create_materials(groups,materials,textures,orbiterpath,param_vector): ''' To create materials, some steps has to be done: 1. Create unique material+texture pairs with corresponding mesh groups 2. Create textures 3. Create materials,assign textures to them if needed, assign materials to mesh groups ''' #1. =======...
raise_small_hardness=param_vector[2] default_hardeness=param_vector[3] if len(materials[idx_mat][3])==5: if raise_small_hardness and (materials[idx_mat][3][4]<default_hardeness): matt[n].specular_hardness=default_hardeness else: matt[n].specular_hardness=materials[idx_mat][3][4] import_emmissive=True; if import_emmi...
if idx_tex>=0: mtex=matt[n].texture_slots.add() mtex.texture=tx[idx_tex] mtex.texture_coords="UV" for grp_idx in pair[1]: groups[grp_idx][5].data.materials.append(matt[n]) n=n+1
def create_materials(groups,materials,textures,orbiterpath,param_vector): ''' To create materials, some steps has to be done: 1. Create unique material+texture pairs with corresponding mesh groups 2. Create textures 3. Create materials,assign textures to them if needed, assign materials to mesh groups ''' #1. =======...
def export_msh(filepath,convert_coords):
def export_msh(filepath,convert_coords,apply_modifiers):
def export_msh(filepath,convert_coords): nonormal=False if os.path.splitext(filepath)[1]=="": filepath=filepath+".msh" file=open(filepath,"w") file.write("MSHX1\n") ngroups=0 for obj in bpy.context.selected_objects: if obj.type=='MESH': ngroups=ngroups+1 file.write("GROUPS {}\n".format(ngroups)) mtrls={} txtrs={} ...
me=obj.data
if (apply_modifiers): me = obj.create_mesh(bpy.context.scene, True, "PREVIEW") else: me=obj.data
def export_msh(filepath,convert_coords): nonormal=False if os.path.splitext(filepath)[1]=="": filepath=filepath+".msh" file=open(filepath,"w") file.write("MSHX1\n") ngroups=0 for obj in bpy.context.selected_objects: if obj.type=='MESH': ngroups=ngroups+1 file.write("GROUPS {}\n".format(ngroups)) mtrls={} txtrs={} ...
vtx.append([matrix*vert.co,vert.normal])
vtx.append([vert.co*matrix,vert.normal])
def export_msh(filepath,convert_coords): nonormal=False if os.path.splitext(filepath)[1]=="": filepath=filepath+".msh" file=open(filepath,"w") file.write("MSHX1\n") ngroups=0 for obj in bpy.context.selected_objects: if obj.type=='MESH': ngroups=ngroups+1 file.write("GROUPS {}\n".format(ngroups)) mtrls={} txtrs={} ...
export_msh(self.filepath,self.convert_coords)
export_msh(self.filepath,self.convert_coords,self.apply_modifiers)
def execute(self,context): print("Export execute") export_msh(self.filepath,self.convert_coords) return {"FINISHED"}
v=ntpath.split(textures[n][0]) print(v); fpath=orbiterpath+"/Textures" for i in v: fpath=fpath+"/"+i print (fpath)
def create_materials(groups,materials,textures,orbiterpath): #counting material/texture combinations print("Creating materials") matpairset=set() matpair=[] # [(mat,tex),[mgroups...]] Unique mat+tex and corresponding groups for n in range(len(groups)): l=(groups[n][1],groups[n][2]) #print(l) if l not in matpa...
try: img=bpy.data.images.load(fpath) except: print("!!!!!Can not load image: ",fpath)
if orbiter_path_ok: v=ntpath.split(textures[n][0]) print(v); fpath=os.path.join(orbiterpath,"Textures") for i in v: fpath=os.path.join(fpath,i) print (fpath) try: img=bpy.data.images.load(fpath) except: print("!!!!!Can not load image: ",fpath) tex_load_fails=tex_load_fails+1 continue else:
def create_materials(groups,materials,textures,orbiterpath): #counting material/texture combinations print("Creating materials") matpairset=set() matpair=[] # [(mat,tex),[mgroups...]] Unique mat+tex and corresponding groups for n in range(len(groups)): l=(groups[n][1],groups[n][2]) #print(l) if l not in matpa...
orbiterpath= StringProperty(name="Orbiter Path", description="Orbiter spacesim path", maxlen=1024, default="/home/vlad/programs/orbiter", subtype="DIR_PATH")
orbiterpath= StringProperty(name="Orbiter Path", description="Orbiter spacesim path", maxlen=1024, default=ORBITER_PATH_DEFALT, subtype="DIR_PATH")
def load_msh(filename,orbiterpath,convert_coords,show_single_sided): '''Read MSH file''' print("filepath=",filename,"orbiterpath=",orbiterpath) file=open(filename,"r") s=file.readline(); if s!='MSHX1\n': print("This file is not orbiter mesh: ",s) return else: print("Orbiter mesh format detected ") n_groups=0 #N of gr...
var=Variable(varname,DATA_TYPES[rhs_type],cast(DATA_TYPES[rhs_type],ctypes.c_long(0)))
if len(node[1])==2: var=Variable(varname,DATA_TYPES[rhs_type],cast(DATA_TYPES[rhs_type],ctypes.c_long(0))) else: raise InterpreterError("Cannot assign to undeclared array %s: "%varname)
def evaluate(self,node): """Evaluator function Evaluates the parse tree rooted at the current node Basically a giant if construct that decides what to do based on the type of node (as found by the string at node[0]) """ if DEBUG: print "Evaluating",node if self.cur_line>=len(self.parse_trees): #reached end of the list...
creationflags=cf, stdin=subprocess.PIPE,
cwd=worker._worker_dir, creationflags=cf, stdin=subprocess.PIPE,
def execute_task(self, task, worker): if sys.platform.startswith("win"): cf=0x08000000 else: cf=0 # Copy any necessary files to the worker directory if task._data_file_zip: shutil.copy(task._data_file_zip, worker._worker_dir) # Pickle the input argument and remove it from the list input_obj_str = pickle.dumps(self._i...
print "stdout test",
print "stdout test"
def print_worker(): print "stdout test", print >> sys.stderr, "stderr test",
print print "ERROR: Test failed to finish after 10 seconds, aborting." print "WARNING: there may be unfinished child processes."
print() print("ERROR: Test failed to finish after 10 seconds, aborting.") print("WARNING: there may be unfinished child processes.")
def killAll(): print print "ERROR: Test failed to finish after 10 seconds, aborting." print "WARNING: there may be unfinished child processes." pgid = os.getpgid(0) os.killpg(pgid, signal.SIGKILL) os.abort()
except Exception, e:
except Exception as e:
def testBadTaskExecution(self): """Checking that an exception raised by execute_task() is properly handled""" self.bad_int.execute_err = 1 task = self.pymw_master.submit_task(null_worker) try: self.pymw_master.get_result(task) except Exception, e: self.assert_(e[0].count("execution error")>0)
except Exception, e:
except Exception as e:
def testBadWorkerFuncs(self): """Checking that failing worker reservation functions are properly handled""" self.bad_int.worker_err = 1 task = self.pymw_master.submit_task(null_worker) try: my_task, my_val = self.pymw_master.get_result(task) except Exception, e: self.assert_(e[0].count("no problem")>0)
except Exception, e:
except Exception as e:
def testProgramError(self): """Checking that exceptions from the worker get passed back correctly""" task = self.pymw_master.submit_task(err_worker) try: self.pymw_master.get_result(task) except Exception, e: self.assert_(e[0].count("integer division or modulo by zero")>0)
task_MR = pymw_mapreduce.submit_task_mapreduce(square, plus, num_tasks, input_data=range(1,21), modules=(), dep_funcs=())
task_MR = pymw_mapreduce.submit_task_mapreduce(square, plus, num_tasks, input_data=list(range(1,21)), modules=(), dep_funcs=())
def testMapReduce(self): """Test standard operation of MapReduce class""" num_tasks = 10 actual_total = 2870 pymw_mapreduce=pymw.PyMW_MapReduce(self.pymw_master) task_MR = pymw_mapreduce.submit_task_mapreduce(square, plus, num_tasks, input_data=range(1,21), modules=(), dep_funcs=()) my_task, result = self.pymw_master.g...
if hasattr(self, "pymw_interface"): self.pymw_master = pymw.PyMW_Master(interface=self.pymw_interface())
if pymw_interface: self.pymw_master = pymw.PyMW_Master(interface=pymw_interface())
def setUp(self): if hasattr(self, "pymw_interface"): self.pymw_master = pymw.PyMW_Master(interface=self.pymw_interface()) else: self.pymw_master = pymw.PyMW_Master() self._kill_timer = threading.Timer(10, killAll) self._kill_timer.start()
self.assert_(e[0].count("execution error")>0)
self.assert_(e.args[0].count("execution error")>0)
def testBadTaskExecution(self): """Checking that an exception raised by execute_task() is properly handled""" self.bad_int.execute_err = 1 task = self.pymw_master.submit_task(null_worker) try: self.pymw_master.get_result(task) except Exception as e: self.assert_(e[0].count("execution error")>0)
self.assert_(e[0].count("no problem")>0)
self.assert_(e.args[0].count("no problem")>0)
def testBadWorkerFuncs(self): """Checking that failing worker reservation functions are properly handled""" self.bad_int.worker_err = 1 task = self.pymw_master.submit_task(null_worker) try: my_task, my_val = self.pymw_master.get_result(task) except Exception as e: self.assert_(e[0].count("no problem")>0)
try: self.pymw_master.get_result(task) except Exception as e: self.assert_(e[0].count("integer division or modulo by zero")>0)
if sys.version_info[0] < 3: try: self.pymw_master.get_result(task) except Exception as e: self.assert_(e.args[0].count("integer division or modulo by zero")>0) else: try: self.pymw_master.get_result(task) except Exception as e: self.assert_(e.args[0].count("int division or modulo by zero")>0)
def testProgramError(self): """Checking that exceptions from the worker get passed back correctly""" task = self.pymw_master.submit_task(err_worker) try: self.pymw_master.get_result(task) except Exception as e: self.assert_(e[0].count("integer division or modulo by zero")>0)
os.write(file[0], "booga")
os.write(file[0], b"booga")
def testSendFiles(self): """Test the packaging and sending of auxiliary data files.""" num_files = 10 file_list = [tempfile.mkstemp() for i in range(num_files)] name_list = [] path_list = tuple([file[1] for file in file_list]) for file in file_list: os.write(file[0], "booga") os.close(file[0]) name_list.append(file[1]...
self.pymw_master = pymw.PyMW_Master(interface=self.pymw_interface)
self.pymw_master = pymw.PyMW_Master(interface=self.pymw_interface())
def setUp(self): if hasattr(self, "pymw_interface"): self.pymw_master = pymw.PyMW_Master(interface=self.pymw_interface) else: self.pymw_master = pymw.PyMW_Master() self._kill_timer = threading.Timer(10, killAll) self._kill_timer.start()
print("|--------------------------------------|") print("| Running test with generic interface. |") print("|--------------------------------------|") pymw_interface = interfaces.generic.GenericInterface() pymw_suite = unittest.TestLoader().loadTestsFromTestCase(TestPyMW) unittest.TextTestRunner(verbosity=2).run(pymw_su...
if len(sys.argv) == 1 or "--generic" in sys.argv: print("|--------------------------------------|") print("| Running test with generic interface. |") print("|--------------------------------------|") pymw_interface = interfaces.generic.GenericInterface pymw_suite = unittest.TestLoader().loadTestsFromTestCase(TestPyMW) ...
def testStandardOperation(self): """Test standard operation with null worker program""" num_tasks = 10 actual_total = num_tasks*(num_tasks-1)/2
pymw_interface = interfaces.boinc.BOINCInterface()
pymw_interface = interfaces.boinc.BOINCInterface
def testStandardOperation(self): """Test standard operation with null worker program""" num_tasks = 10 actual_total = num_tasks*(num_tasks-1)/2
pymw_interface = interfaces.condor.CondorInterface()
pymw_interface = interfaces.condor.CondorInterface
def testStandardOperation(self): """Test standard operation with null worker program""" num_tasks = 10 actual_total = num_tasks*(num_tasks-1)/2
pymw_interface = interfaces.ganga.GANGAInterface()
pymw_interface = interfaces.ganga.GANGAInterface
def testStandardOperation(self): """Test standard operation with null worker program""" num_tasks = 10 actual_total = num_tasks*(num_tasks-1)/2
pymw_interface = interfaces.grid_simulator.GridSimulatorInterface()
pymw_interface = interfaces.grid_simulator.GridSimulatorInterface
def testStandardOperation(self): """Test standard operation with null worker program""" num_tasks = 10 actual_total = num_tasks*(num_tasks-1)/2
pymw_interface = interfaces.mpi.MPIInterface()
pymw_interface = interfaces.mpi.MPIInterface
def testStandardOperation(self): """Test standard operation with null worker program""" num_tasks = 10 actual_total = num_tasks*(num_tasks-1)/2
pymw_interface = interfaces.multicore.MulticoreInterface()
pymw_interface = interfaces.multicore.MulticoreInterface
def testStandardOperation(self): """Test standard operation with null worker program""" num_tasks = 10 actual_total = num_tasks*(num_tasks-1)/2
pymw_interface = interfaces.multiproc.MultiProcInterface() pymw_suite = unittest.TestLoader().loadTestsFromTestCase(TestPyMW) unittest.TextTestRunner(verbosity=2).run(pymw_suite)
pymw_interface = interfaces.multiproc.MultiProcInterface pymw_suite = unittest.TestLoader().loadTestsFromTestCase(TestPyMW) unittest.TextTestRunner(verbosity=2).run(pymw_suite)
def testStandardOperation(self): """Test standard operation with null worker program""" num_tasks = 10 actual_total = num_tasks*(num_tasks-1)/2
if (i[0] == "directory"):
try: pstat = os.lstat(i[2])[stat.ST_MODE] except: continue if (not self.isApplicationOwned(i[2], safe_app_dir)): log.showInfoW("Ignoring " + i[2] + " because it's not owned by the application.") continue if (i[0] == "directory" and not stat.S_ISLNK(pstat)):
def unlink(self): """Unlink an application from the base filesystem.""" adiff = ApplicationDifferencer()
elif (i[0] == "file" and stat.S_ISLNK(os.lstat(i[2])[stat.ST_MODE])): try:
elif ((i[0] == "file" or i[0] == "directory") and stat.S_ISLNK(pstat)): try: log.showInfoW(" * " + i[2])
def unlink(self): """Unlink an application from the base filesystem.""" adiff = ApplicationDifferencer()
else:
elif (i[0] != "notexists" and i[0] != "file" and i[0] != "directory"):
def unlink(self): """Unlink an application from the base filesystem.""" adiff = ApplicationDifferencer()
i = (i[0], i[1], n)
sv = self.getNormalizedApplicationPath(self.version, i[1]) i = (i[0], sv, n)
def link(self): """Link an application to the base filesystem.""" adiff = ApplicationDifferencer()
self.name + "/" + self.version
self.name
def unlink(self): """Unlink an application from the base filesystem.""" adiff = ApplicationDifferencer()
if (not i[0] == "directory"):
if (not is_directory):
def unlink(self): """Unlink an application from the base filesystem.""" adiff = ApplicationDifferencer()
if (i[0] == "directory" and stat.S_ISLNK(pstat)):
if (is_directory and stat.S_ISLNK(pstat)):
def unlink(self): """Unlink an application from the base filesystem.""" adiff = ApplicationDifferencer()
def create(self,name="",pname="",width=-1,height=-1,mines=-1,defaultmines=1):
def create(self,name="",pname="",width=-1,height=-1,mines=-1,defaultmines=1,wrap=False):
def create(self,name="",pname="",width=-1,height=-1,mines=-1,defaultmines=1): if defaultmines=='true': mines=-1 width = int(width) height = int(height) mines = int(mines)
if wrap=='true': wrap=True else: wrap=False
def create(self,name="",pname="",width=-1,height=-1,mines=-1,defaultmines=1): if defaultmines=='true': mines=-1 width = int(width) height = int(height) mines = int(mines)
newgame = Game(name,width,height,mines)
newgame = Game(name,width,height,mines,wrap)
def create(self,name="",pname="",width=-1,height=-1,mines=-1,defaultmines=1): if defaultmines=='true': mines=-1 width = int(width) height = int(height) mines = int(mines)
r=''
r=[]
def encodetiles(self,tilelist): if not tilelist: return '' r='' for t in tilelist: #The browser swaps the X and Y values, it seems. r+="%d%d%d"%(t.pos[1],t.pos[0],t.uncovered) if t.bomb: r+="X" else: r+=str(t.adjacency) return r
r+="%d%d%d"%(t.pos[1],t.pos[0],t.uncovered)
r.append({ 'x':t.pos[1], 'y':t.pos[0], 'pl':t.uncovered })
def encodetiles(self,tilelist): if not tilelist: return '' r='' for t in tilelist: #The browser swaps the X and Y values, it seems. r+="%d%d%d"%(t.pos[1],t.pos[0],t.uncovered) if t.bomb: r+="X" else: r+=str(t.adjacency) return r
r+="X"
r[-1]['val']="X"
def encodetiles(self,tilelist): if not tilelist: return '' r='' for t in tilelist: #The browser swaps the X and Y values, it seems. r+="%d%d%d"%(t.pos[1],t.pos[0],t.uncovered) if t.bomb: r+="X" else: r+=str(t.adjacency) return r
r+=str(t.adjacency) return r
r[-1]['val']=t.adjacency return r
def encodetiles(self,tilelist): if not tilelist: return '' r='' for t in tilelist: #The browser swaps the X and Y values, it seems. r+="%d%d%d"%(t.pos[1],t.pos[0],t.uncovered) if t.bomb: r+="X" else: r+=str(t.adjacency) return r
if data: return json.dumps({'reveal':data,'players': [{'name':p.name} for p in game.players]})
response = json.dumps({'reveal':data,'players': [{'name':p.name} for p in game.players]})
def default(self,*args,**kwargs): response = "" id = args[0] player = self.get_session_player() action = kwargs.get('action','') if id in Game.games: game = Game.games[id] else: raise Exception, "Invalid game ID" if action=='click': data = self.clickresponse(game, player, int(kwargs['x']), int(kwargs['y'])) if data: se...
raise BoardTooSmallException, "The game board (%dx%d) must be larger than 3x3."%(width,height)
raise BoardTooSmallError, "The game board (%dx%d) must be larger than 3x3."%(width,height)
def __init__(self,width,height,bombs=-1,wrap=False): if width<4 or height<4: raise BoardTooSmallException, "The game board (%dx%d) must be larger than 3x3."%(width,height) #Set settings self.width=width self.height=height self.bombs=bombs self.wrap=wrap if bombs==-1: self.bombs = int(((width*height)-9)/7) if width*he...
raise BoardTooManyBombsException, "%d bombs is too many. The largest allowed number of bombs is width*height-14 = %d"%(self.bombs,width*height-14)
raise BoardTooManyBombsError, "%d bombs is too many. The largest allowed number of bombs is width*height-14 = %d"%(self.bombs,width*height-14)
def __init__(self,width,height,bombs=-1,wrap=False): if width<4 or height<4: raise BoardTooSmallException, "The game board (%dx%d) must be larger than 3x3."%(width,height) #Set settings self.width=width self.height=height self.bombs=bombs self.wrap=wrap if bombs==-1: self.bombs = int(((width*height)-9)/7) if width*he...
raise BoardCoordOutOfRangeExcepton, "Tile coordinate (%d,%d) out of bounds"%(x,y)
raise BoardCoordOutOfRangeError, "Tile coordinate (%d,%d) out of bounds"%(x,y)
def set_bomb(self,x,y): if self.is_bomb(x,y): return False t = self.get_tile(x,y) if t==None: raise BoardCoordOutOfRangeExcepton, "Tile coordinate (%d,%d) out of bounds"%(x,y) t.bomb = True for x in self.get_adjacent_tiles(x,y): x.adjacency+=1 return True
def reveal(self,player,x,y, list=[]): if list==[]: first=True else: first=False
def reveal(self,player,x,y): ret = self._recurse_reveal(player, x, y) for l in self.tiles: for t in l: t._checked = False return ret def _recurse_reveal(self,player,x,y):
def reveal(self,player,x,y, list=[]): if list==[]: first=True else: first=False t = self.get_tile(x,y) if t._checked == True: return if not t: raise BoardCoordOutOfRangeExcepton, "Tile coordinate (%d,%d) out of bounds"%(x,y) t._checked = True if t.uncovered == 0: t.uncovered = player list.append(t) if t.adjacency==0: f...
if t._checked == True: return if not t: raise BoardCoordOutOfRangeExcepton, "Tile coordinate (%d,%d) out of bounds"%(x,y)
if not t: return if t._checked: return
def reveal(self,player,x,y, list=[]): if list==[]: first=True else: first=False t = self.get_tile(x,y) if t._checked == True: return if not t: raise BoardCoordOutOfRangeExcepton, "Tile coordinate (%d,%d) out of bounds"%(x,y) t._checked = True if t.uncovered == 0: t.uncovered = player list.append(t) if t.adjacency==0: f...
list.append(t)
ret = [t]
def reveal(self,player,x,y, list=[]): if list==[]: first=True else: first=False t = self.get_tile(x,y) if t._checked == True: return if not t: raise BoardCoordOutOfRangeExcepton, "Tile coordinate (%d,%d) out of bounds"%(x,y) t._checked = True if t.uncovered == 0: t.uncovered = player list.append(t) if t.adjacency==0: f...
for a in self.get_adjacent_tiles(x, y): self.reveal(player,*a.pos,list=list) if first: for l in self.tiles: for t in l: t._checked = False
for xx in range(x-1,x+2): for yy in range(y-1,y+2): con = self._recurse_reveal(player,xx,yy) if con: ret += con t._checked=1 return ret
def reveal(self,player,x,y, list=[]): if list==[]: first=True else: first=False t = self.get_tile(x,y) if t._checked == True: return if not t: raise BoardCoordOutOfRangeExcepton, "Tile coordinate (%d,%d) out of bounds"%(x,y) t._checked = True if t.uncovered == 0: t.uncovered = player list.append(t) if t.adjacency==0: f...
b.reveal(1,0,0)
def __str__(self): s="" for x in self.tiles: for y in x: s+="%s "%str(y).center(3) s+="\n" return s
name = cherrypy.request.cookie.get('name','').value
name = self.get_cookie_name()
def get_session_player(self,game,name=''): if name=="": name = cherrypy.request.cookie.get('name','').value id = cherrypy.session.get(game.id) if id==None and name!='': p = game.add_player(name) cherrypy.session[game.id] = p.id cherrypy.response.cookie['name'] = name cherrypy.response.cookie['name']['expires'] = 60*60*...
'name': cherrypy.request.cookie.get('name','').value
'name': self.get_cookie_name()
def index(self): data = { 'title':website_title, 'games':Game.games.values(), 'numgames':len(Game.games.values()), 'name': cherrypy.request.cookie.get('name','').value } t = Template(file='html/index.html',searchList=[data]) return t.respond()
return open('static/index.html').read()
data = {} data['title']='MultiMines' data['games']=[] data['numgames'] = max(len(data['games']),10) t = Template(file='html/index.html',searchList=[data]) return t.respond()
def index(self): return open('static/index.html').read()
InputThread().start()
def run(self): go = True while go: cmd = raw_input(">") if cmd=="exit": go = False cherrypy.engine.exit()
cherrypy.config.update('config.cfg') cherrypy.quickstart(Root(),'/')
InputThread().start() cherrypy.quickstart(Root(),'/','config.cfg')
def run(self): go = True while go: cmd = raw_input(">") if cmd=="exit": go = False cherrypy.engine.exit()
try: f = open(filename) except IOError, e: err('%s\n' % e.strmessage) sys.exit(1)
try: f = open(filename) except IOError, e: err('%s\n' % e.strmessage) sys.exit(1) self.file = f.read( )
def load_file(self, filename): if not os.access(filename, os.R_OK): err('could not open %s for reading!\n' % filename) sys.exit(1)
self.file = f.read( )
def load_file(self, filename): if not os.access(filename, os.R_OK): err('could not open %s for reading!\n' % filename) sys.exit(1)
cat >/tmp/etc/yum.repos.d/beaker-tests.repo <<REPO_END
if [[ -n "$BEAH_MAKE_REPOS" ]]; then cat >/etc/yum.repos.d/beaker-tests.repo <<REPO_END
def content(self): self.write_line("""
if os.path.isfile(fn):
if os.path.isfile(fname):
def get_file(fname): if os.path.isabs(fname): if os.path.isfile(fn): return fname else: for rt in get_data_root(): fn = rt+'/'+fname if os.path.isfile(fn): return os.path.abspath(fn)
if os.path.isdir(fn):
if os.path.isdir(fname):
def get_dir(fname): if os.path.isabs(fname): if os.path.isdir(fn): return fname else: for rt in get_data_root(): fn = rt+'/'+fname if os.path.isdir(fn): return os.path.abspath(fn)
def make_object(cls, id, parent, args):
def make_object(cls, id, parent, args={}):
def make_object(cls, id, parent, args): result = cls(id, parent) type = result.result_type(args.get('rc', None)) handle = args.get('handle', '%s/%s' % \ (parent.name(), id)) statistics = args.get('statistics') or {} score = statistics.get('score', 0) message = args.get('message', '') or parent.backend().mk_msg(args=arg...
def read_object(cls, id, parent, args):
def read_object(cls, id, parent, args={}):
def read_object(cls, id, parent, args): result = cls(id, parent) if result.beaker_id == self.PENDING_RESULT: raise KeyError("The result '%s' did not get through." % id)
return False
return True
def pre_proc(self, evt): id = evt.task_id = self.get_evt_task_id(evt) if id is None: return False if evt.event() == 'file_write': evt = event.Event(evt) evt.args()['data'] = '...hidden...' self.get_writer(id, '.task_beah_raw').write(jsonln(evt)) return False
GUEST_ATTRS = ('guestname', 'mac_address', 'location', 'install_name', 'guestargs')
GUEST_ATTRS = ('system', 'mac_address', 'location', 'guestargs', 'install_name')
def parse_recipe_xml(input_xml, hostname): root = minidom.parseString(input_xml) for er in root.getElementsByTagName('recipe'): system = xml_attr(er, 'system') if system == hostname: break else: log.info("parse_recipe_xml: No recipe for %s." % hostname) return None task_env = {} rs = xml_attr(er, 'status') if rs not ...