How to use is_valid_directory method in autotest

Best Python code snippet using autotest_python

rcs.py

Source:rcs.py Github

copy

Full Screen

...22 return contents23 except IOError:24 logger.debug("Error reading working copy: {}".format(os.path.join(path, filename)))25 raise IOError("Error reading working copy: {}".format(os.path.join(path, filename)))26 def is_valid_directory(self, path):27 """ Return wheter or not the directory is a valid RCS repository28 :param path: Path of the dir29 :return: True/False30 """31 pass32 def is_commit(self, path, commit):33 """ Return wheter or not the commit is a valid commit34 :param path: path of the repository35 :param commit: Commit name36 :return: True/False37 """38 pass39 def get_relative_paths(self, filename):40 """ Return the root path of the repository41 :param path: path of the file containing the path42 :return: the root path, the relative path and the filename43 """44 pass45class Git(RCS):46 """ Git Revision Control System class """47 def show_file(self, path, commit, filename):48 49 # Use current working copy50 if commit is None:51 return super(Git, self).show_file(path, commit, filename)52 53 # Execute 'git show' command and return content or empty string54 git_show_command = "git show %s:%s" % (commit, filename)55 ret, file_content = run_command(git_show_command, path)56 # Does the file exist ?57 if ret:58 # Return code != 0, file not found for this commit59 file_content = ""60 return file_content.strip()61 def is_valid_directory(self, path):62 # Verify that path is a valid repository63 # Following command do :64 # - jump to path65 # - git status66 # - jump back to the current dir67 git_status_command = "git status"68 ret, output = run_command(git_status_command, path)69 # Does the repository is a valid RCS dir70 return ret == 071 def is_commit(self, path, commit):72 # Execute 'git show' command and return True of False according to ret code73 git_show_command = "git show %s" % (commit)74 ret, output = run_command(git_show_command, path)75 # Valid commit ?76 return ret == 077 def get_relative_paths(self, filename):78 path = os.path.dirname(filename)79 path = '.' if path == '' else path80 # Get the root path of the repository81 git_path_command= "git rev-parse --show-toplevel"82 ret, root_path = run_command(git_path_command, path)83 root_path = os.path.abspath(root_path.strip())84 # Get the relative path of the file85 relative_path = os.path.dirname(os.path.abspath(filename)[len(root_path)+1:])86 filename = os.path.basename(filename)87 return root_path, relative_path, filename88class SVN(RCS):89 """ SVN Revision Control System class """90 def show_file(self, path, commit, filename):91 # Use current working copy92 if commit is None:93 return super(SVN, self).show_file(path, commit, filename) 94 95 # Execute 'svn cat' command and return content or empty string96 svn_cat_command = "svn cat -r %s %s" % (commit, filename)97 ret, file_content = run_command(svn_cat_command, path)98 # Does the file exist ?99 if ret:100 # Return code != 0, file not found for this commit101 file_content = ""102 return file_content.strip()103 def is_valid_directory(self, path):104 # Verify that path is a valid repository105 # Following command do :106 # - jump to path107 # - svn info108 # - jump back to the current dir109 svn_status_command = "svn info"110 ret, output = run_command(svn_status_command, path)111 # Does the repository is a valid RCS dir112 return ret == 0113 def is_commit(self, path, commit):114 # Execute 'svn show' command and return True of False according to ret code115 svn_info_command = "svn info -r %s" % (commit)116 ret, output = run_command(svn_info_command, path)117 # Valid commit ?118 return ret == 0119 def get_relative_paths(self, filename):120 # In the case of SVN, we can consider use SVN commands whatever the path is121 # So we don't differentiate root and relative paths122 # Get the root path of the repository123 root_path = os.path.dirname(os.path.abspath(filename))124 relative_path = ""125 filename = os.path.basename(filename)126 return root_path, relative_path, filename127# Contains all classes128_RCS = []129for cls in RCS.__subclasses__():130 _RCS.append(cls())131def get_rcs_class(path):132 """ Get the RCS class133 :param path: path of the file134 :return: the rcs instance or None if no class is valid135 """136 for cls in _RCS:137 if cls.is_valid_directory(path):138 return cls...

Full Screen

Full Screen

SBGolfConverter.py

Source:SBGolfConverter.py Github

copy

Full Screen

...16 for f, l in zip(repeat_to_length(first, 3), repeat_to_length(last, 3)):17 if len(subject_name) <= 5:18 subject_name += l + f19 return subject_name.lower()20def is_valid_directory(directory):21 path = Path(directory)22 return path.exists() and path.is_dir()23def create_output_directory():24 # Create Output Directory25 if is_valid_directory(OUTPUT_DIR):26 output_path = os.path.join(ROOT_DIR, OUTPUT_DIR)27 shutil.rmtree(output_path) 28 output_path = Path(OUTPUT_DIR)29 output_path.mkdir(parents=True, exist_ok=True)30 print("Directory '% s' has been created successfully" % output_path)31def main():32 try:33 print("Starting Data conversion process ...")34 print('Scanning data root directory: ' + ROOT_DIR)35 if not is_valid_directory(ROOT_DIR):36 print('Data root directory does not exist: ' + ROOT_DIR)37 return38 39 # Create Output directory40 create_output_directory()41 ###### Start process to conversion ################42 for root, subdirectories, files in os.walk(ROOT_DIR, topdown=True):43 subdirectories[:] = [d for d in subdirectories if d not in OUTPUT_DIR]44 for directory in subdirectories:45 print(' > Querying sub-directories: ' + directory)46 subject_file = Path(ROOT_DIR, directory).rglob('*.sbj')47 rw3_files = Path(ROOT_DIR, directory).rglob('~*.rw3')48 49 for path in subject_file:...

Full Screen

Full Screen

test_wsr_automation_trigger.py

Source:test_wsr_automation_trigger.py Github

copy

Full Screen

2from wsr_automation_trigger import *3WSR_automation = WSR_automation()4def setup():5 WSR_automation.__init__()6def test_is_valid_directory():7 assert (wsr_automation_trigger.is_valid_directory("hardcoded_value: correct value with proper excel files"))8 assert not (wsr_automation_trigger.is_valid_directory("hardcoded_value: incorrect directory"))9 assert not (wsr_automation_trigger.is_valid_directory("hardcoded_value: correct value with improper excel files"))10def test_delete_existing_file_prefix():11 assert (wsr_automation_trigger.delete_existing_file_prefix("hardcoded_value: correct value "))12 assert not (wsr_automation_trigger.delete_existing_file_prefix("hardcoded_value: correct value;open file "))13 assert not (wsr_automation_trigger.delete_existing_file_prefix("hardcoded_value: incorrect value "))14def teardown():...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful