def getScripts(self, hostname): scripts = [] for f in next(walkdir(self.configuration['host_dir']+'/'+hostname+'/'))[2]: if self.re_script.match(f): scripts.append('.'.join(f.split('.')[:-1])) return scripts
def ui(request): svgs = [] pngs = [] gifs = [] for path, __, files in walkdir('assets/v2/images'): if path.find('/avatar') != -1: continue for f in files: if f.endswith('.svg'): svgs.append(f'{path[7:]}/{f}') continue if f.endswith('.png'): pngs.append(f'{path[7:]}/{f}') continue if f.endswith('.gif'): gifs.append(f'{path[7:]}/{f}') continue context = { 'is_outside': True, 'active': 'ui_inventory ', 'title': 'UI Inventory', 'svgs': svgs, 'pngs': pngs, 'gifs': gifs, } return TemplateResponse(request, 'ui_inventory.html', context)
def run_tree(dir, func, prefix=None, **kargs): _, subdir, files = walkdir(dir).next() # logger.debug('Running on %s', dir) if len(files) > 0: logger.debug("Files: %s", ', '.join(files)) if len(subdir) > 0: for child in subdir: run_tree(path.join(dir, child), func, prefix, **kargs) func(dir, files, prefix, **kargs)
def test_one_login(self): # global cookiefile cookiefile = None print('\n----> ' + str(self._testMethodName) + '\n') # GET python version & Browser version driver = self.driver from sys import version as pythonversion print('Python Version = ' + pythonversion) print('Browser version ( ' + self.driver.name + ' ) = ' + self.driver.capabilities['version']) # Python 3.7 and below # print('Browser version ( ' + self.driver.name + ' ) = ' + self.driver.capabilities['browserVersion']) # Python 3.8 & above print() user1 = self.__class__.userone pswd1 = self.__class__.pswdone if driver.name == 'chrome': driver.maximize_window() driver.get(self.base_url) driver.find_element_by_name('username').click() driver.find_element_by_name('username').send_keys(user1 + Keys.ENTER) driver.find_element_by_name('password').click() driver.find_element_by_name('password').send_keys(pswd1 + Keys.ENTER) ## read cookie data and put to cookies variable at the top of the class # preferencesfile = "Preferences" # cookiesfile_r = open(self.__class__.chromedatadir + '/\Default/\/' + preferencesfile, "rb") # print("COOKIESFILE = " + str(cookiesfile_r)) # self.__class__.cookies = pickle.load(cookiesfile_r) # print('COOKIES = ' + str(self.__class__.cookies)) # cookiesfile_r.close() # sleep(2) files = [] preferencesfile = "Preferences" for dirpath, dirname, filename in walkdir( self.__class__.chromedatadir): for file in filename: if file == preferencesfile: files.append(joinname(dirpath, file)) cookiefile = files[0] print("COOKIEFILE = " + str(cookiefile)) fopenfile = open(str(cookiefile), 'r') lines = fopenfile.readlines() # self.__class__.cookies = pickle.load(fopenfile) self.__class__.cookies = [x for x in lines] fopenfile.close() sleep(2) print('COOKIES = ' + str(self.__class__.cookies)) ## current URL print('CURRENT URL = ' + driver.current_url) self.__class__.mengkome_url = driver.current_url
from os import walk as walkdir from os.path import join as joinname chromedatadir = 'chrome-data' files = [] preferencesfile = 'Preferences' for dirpath, dirname, filename in walkdir(chromedatadir): for file in filename: if file == preferencesfile: files.append(joinname(dirpath, file)) print('FILES = ' + str(files[0])) # print("COOKIEFILE = " + str(cookiefile))
def getHosts(self): return next(walkdir(self.configuration['host_dir']))[1] def getScripts(self, hostname):
def walk(): for (path, dirname, filename) in os.walkdir(inpDir): if filename.endswith(".html"): process(path, dirname, filename) return