def isModuleInCurrentFolder(pathIn,moduleIn): #print("into isMICF") from os.path import exists #ignore pathIn, just check current folder if exists(moduleIn): return True else: return False #if end #def end def FRUM_extract(pkgName,module): from commandOS import commandOS #print("@15 into FRUM_extract") #try to extract the module cmd="python /home/pi/Desktop/IX_assets/ix/textselect.py "+module+" <"+pkgName #print("cmd:"+cmd) result=commandOS(cmd) #print("result :"+result+":") #print("issue 01: selected initCD2.py into the IX_assets/ix folder") cmd="ls -ls "+module result=commandOS(cmd) result=result.strip() result=result.strip("\n") path="" #only check the current folder for the moment #print("@29, module:"+module) if isModuleInCurrentFolder(path,module): #print("@31 moduleIn:"+module) print("FNUM success: fetched: "+module) else: print("Warning FNUM failed to fetch: "+module) #if end #print("@36, moduleIn:"+module) #print("@37 end of text select") # result is selected module name return result #def end FRUM_extract() def FRUM_n(repository,module): from commandOS import commandOS #print("@45 into FRUM_n") isN=False if repository!="" and module=="n" : isN=True arg="-m" #if end if repository!="" and module=="n-all" : isN=True arg="-all" #if end if isN==True : #print("@56 isN is True") #list the directory of the repository print("@58 FRUM("+repository+","+module+',""') cmd="python /home/pi/Desktop/IX_assets/ix/n_v07.py "+arg+" <"+repository #print("@59 cmd:"+cmd) result=commandOS(cmd) #print("@61 result:"+result) resultFile="/home/pi/Desktop/PiR2/files/commandResult.txt" if result[0:22]=="#::: Enhanced n.py v07": #print("@65 result is in:"+".../commandResult.txt") file1 = open(resultFile, 'r') for ii in file1 : print(ii, end=" ") #for end #end for else: print("#73 WARNING bad command") #if end return isN #return True if n dir was requested #def end n() def FRUM(repositoryIn,moduleIn,altName): #print("into FRUN") from commandOS import commandOS #acronym: Fetch..Requires..Uses..Module #By D@CC #Date: 2024CMar19 #Purpose: to fetch or invoke a module #Parm0: repository (pkg) or "" meaning current folder #Parm1: module name if null error result="" isError=True if moduleIn=="" : # empty result is null module name return result # in case of error else: module=moduleIn #use module name asis #if end path="/home/pi/Desktop/IX_assets/ix/" repository=repositoryIn #default #print("@96: repository:"+repository) if repositoryIn=="": path="" repository="" if repositoryIn=="e": repository="ePkg_py.py" if repositoryIn=="m": repository="mPkg_py.py" if repositoryIn=="f": repository="pkg_py.py" if repositoryIn=="t": repository="pkg_textpack_py.py" #if end #print("@109: repository:"+repository) pkgName=path+repository #if end if repository!="": #test if n for package outline (if so do it and return True #print("@116 pkgName:"+pkgName) #print("@117 module:",module) if not FRUM_n(pkgName,module): # n dir was not requested # so fetch the module # if it doesn't exist if isModuleInCurrentFolder(path,module): print("Warning: found: "+module+":") return "module exists: "+module+":" else: #print("@126 not found") FRUM_extract(pkgName,module) #if end #if end else: #read module as a file from the current folder result="WARNING: empty repository name" pass #if end #print("@135 result:",result) return result #def end def FRUM_test(): #by: D@CC #on: 2024CMar20 #Purpose: Test FRUN #For: IXf #Uses: isModuleInCurrentFolder() # FRUN() # commandOS() # print("Enter pkg,module,parm3 for FRUM") while True: pkg=input("pkg: ") module=input("module: ") p3=input("parm3: ") if pkg=="" and module=="" and p3=="" : print("@153 end of FRUM") return else: if p3=="": p3='""' #if end print("FRUM("+pkg+","+module+","+p3+")") file=FRUM(pkg,module,p3) print("result:"+file) #if end #while end #def end FRUN_test if __name__ == "__main__" : FRUM_test() #/def FRUM.py