How to use _verify_path method in autotest

Best Python code snippet using autotest_python

djangoctl.py

Source:djangoctl.py Github

copy

Full Screen

...21class Django(func_module.FuncModule):22 version = "0.0.1"23 api_version = "0.0.1"24 description = "Django control module."25 def _verify_path(self, project_path):26 """27 Verifies the project path exists and is readable.28 project_path is the path to the Django project.29 """30 # Verify path exists31 if not os.access(project_path, os.F_OK):32 raise exceptions.OSError(33 "Path %s doesn't exist." % project_path)34 # .. and that we can read it35 if not os.access(project_path, os.R_OK):36 raise exceptions.OSError(37 "Path %s is not readable." % project_path)38 return True39 def _get_settings(self, project_path):40 """41 Gets the settings object.42 project_path is the path to the Django project.43 """44 self._verify_path(project_path)45 # Append the settings to the path46 sys.path.append(project_path)47 import settings48 del sys.path[-1]49 return settings50 def settings(self, project_path):51 """52 Simple gets the settings for a specific application.53 project_path is the path to the Django project.54 """55 self._verify_path(project_path)56 settings = self._get_settings(project_path)57 items = {}58 # for each item in settings attempt to append the setting to items59 for item in dir(settings):60 # ... assuming it isn't _*61 if item[1] != '_':62 setting = getattr(settings, item)63 # See if we can directly append64 if type(setting) in [types.TupleType,65 types.StringType,66 types.DictType,67 types.ListType]:68 items[item] = setting69 else:70 # Else force it to a string71 items[item] = str(setting)72 # Remove the settings from the path73 return items74 def setting(self, project_path, a_setting):75 """76 Returns a single setting.77 project_path is the path to the Django project.78 """79 items = self.settings(project_path)80 return items[a_setting]81 def manage(self, project_path, command):82 """83 Executes django-admin.py adding the path and settings84 variables for a command.85 project_path is the path to the Django project.86 command is the command to run.87 """88 self._verify_path(project_path)89 settings = self._get_settings(project_path)90 command = "django-admin.py %s --pythonpath=%s --settings=settings" % (91 command, project_path)92 cmdref = sub_process.Popen(command.split(), stdout=sub_process.PIPE,93 stderr=sub_process.PIPE, shell=False,94 close_fds=True)95 data = cmdref.communicate()96 return (cmdref.returncode, data[0], data[1])97 def environment(self, project_path):98 """99 Gets the environment information that the project is running on.100 project_path is the path to the Django project.101 """102 self._verify_path(project_path)103 import platform104 from django import get_version105 return {'django_version': get_version(),106 'uname': platform.uname(),107 'dist': platform.dist(),...

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