def add_profile(profile): if config.has_section(profile): logger.log_r(profile + " Section already exists!!") return config.add_section(profile) write_config()
def get_index_input(list, query): if len(list) == 0: logger.log_c("\n" + query + " list size is 0 !! Exiting program\n"); exit() logger.log_c("\nSelect one " + query + " from the list: \n") index = 1 for item in list: logger.log_r(str(index) + ". " + item.split('/')[1]) index = index + 1; index = click.prompt("\nYour Options? :" , default=1, type=int) logger.log_c("\nSelected Input for " + query + " : " + list[index - 1].split('/')[1]); return list[index - 1].split('/')[1]
def get_env(profile, key): logger.debug("Searching in profile : " + profile) logger.debug("Searching in key" + key) if config.has_option(profile, key): return config.get(profile, key) logger.debug("Not found in current profile") if config.has_option('default', key): return config.get('default', key) logger.debug("No Value Found in DEAFULT SECTION as well") logger.log_r( 'Value not found in [Default Profile] use `dokr configure`comamnd') exit()
def execute(input_path, defaultTimePage): logger.log_r("Printing the entire list") # index =0 # creating list list = [] index = 0 with open(input_path, 'r') as f: for url in f: # openUrlAndTakeScreenshot(url, defaultTimePage, str(index) + '.png') list.append(ResultRow(index, url)) logger.log_g(str(index)) index = index+1 logger.log_r("Printing the entire list") for obj in list: percentage = compareImages('0.png', str(obj.index) + '.png') logger.log_g("percentage : " + str(percentage)) obj.imgPer = percentage print(obj.index, obj.url, obj.imgPer, sep =' ' ) print_results(list)
def push_image(search_pattern): logger.log_c("\nSearching images matching this pattern : " + search_pattern) image_name = utils.cmd_exec("docker images | cut -d ' ' -f1 | grep " + search_pattern + " | head -1") logger.log_y("\nFound this image name from the given pattern : " + image_name) if image_name == '': logger.log_r("No such found to push !!! Exiting !!!") exit() image_list_str = "docker image inspect -f '{{join .RepoTags \"\\n\" }}' " + image_name logger.debug("\nFinding images tags") image_list = utils.cmd_exec(image_list_str) logger.debug("\nFound Following images : \n\n" + image_list) tag_list = utils.cmd_exec(image_list_str).split("\n") logger.log_c('\nTotal Tags found : ', str(len(tag_list))) for tag in tag_list: logger.log_c('\n--------------------------Pushing image :' + tag + '-----------------------------------') utils.cmd_exec('docker push ' + tag)
def get_config_path(): homedir = os.environ.get('HOME', None) logger.debug("Home Directory: " + homedir) if not homedir: logger.log_r("Home Directory Not found!! Set Envirnoment `HOME` ") exit() logger.debug("Home Directory : " + homedir) config_file = os.path.join(homedir + "/.dokr/config") logger.debug("Config File Location : " + config_file) if not os.path.exists(config_file): logger.log_r("ERROR: No Config file present") try: os.makedirs(os.path.dirname(config_file)) except OSError as exc: # Guard against race condition logger.log_r("Directory found! but not config file") logger.debug("Creating config file") file = open(config_file, "w") file.write("[default]") file.close() logger.debug(config.read(config_file)) return config_file
def webshot(filepath, divclass): # pragma: no cover logger.log_r("filepath got initialized : " + filepath) ss.execute(filepath, 20)