How to use get_logging_manager method in autotest

Best Python code snippet using autotest_python

logging_.py

Source:logging_.py Github

copy

Full Screen

...31 """32 @utilities.format_response33 def DELETE(self, log_id):34 try:35 logm = logutils.get_logging_manager()36 logm.delete_log(utilities.clean_id(log_id))37 return utilities.success()38 except IllegalState as ex:39 modified_ex = type(ex)('Log is not empty.')40 utilities.handle_exceptions(modified_ex)41 except Exception as ex:42 utilities.handle_exceptions(ex)43 @utilities.format_response44 def GET(self, log_id):45 try:46 logm = logutils.get_logging_manager()47 log = logm.get_log(utilities.clean_id(log_id))48 log = utilities.convert_dl_object(log)49 return log50 except Exception as ex:51 utilities.handle_exceptions(ex)52 @utilities.format_response53 def PUT(self, log_id):54 try:55 logm = logutils.get_logging_manager()56 form = logm.get_log_form_for_update(utilities.clean_id(log_id))57 utilities.verify_at_least_one_key_present(self.data(), ['name', 'description'])58 # should work for a form or json data59 if 'name' in self.data():60 form.display_name = self.data()['name']61 if 'description' in self.data():62 form.description = self.data()['description']63 updated_log = logm.update_log(form)64 updated_log = utilities.convert_dl_object(updated_log)65 return updated_log66 except Exception as ex:67 utilities.handle_exceptions(ex)68class LogsList(utilities.BaseClass):69 """70 List all available logs.71 api/v2/logging/logs/72 POST allows you to create a new log, requires two parameters:73 * name74 * description75 Alternatively, if you provide an assessment bank ID,76 the log will be orchestrated to have a matching internal identifier.77 The name and description will be set for you, but can optionally be set if78 provided.79 * bankId80 * name (optional)81 * description (optional)82 Note that for RESTful calls, you need to set the request header83 'content-type' to 'application/json'84 Example (note the use of double quotes!!):85 {"name" : "a new log",86 "description" : "this is a test"}87 OR88 {"bankId": "assessment.Bank%3A5547c37cea061a6d3f0ffe71%40cs-macbook-pro"}89 """90 @utilities.format_response91 def GET(self):92 """93 List all available logs94 """95 try:96 logm = logutils.get_logging_manager()97 logs = logm.logs98 logs = utilities.extract_items(logs)99 return logs100 except Exception as ex:101 utilities.handle_exceptions(ex)102 @utilities.format_response103 def POST(self):104 """105 Create a new log, if authorized106 """107 try:108 logm = logutils.get_logging_manager()109 if 'bankId' not in self.data():110 utilities.verify_keys_present(self.data(), ['name', 'description'])111 form = logm.get_log_form_for_create([])112 finalize_method = logm.create_log113 else:114 log = logm.get_log(Id(self.data()['bankId']))115 form = logm.get_log_form_for_update(log.ident)116 finalize_method = logm.update_log117 if 'name' in self.data():118 form.display_name = self.data()['name']119 if 'description' in self.data():120 form.description = self.data()['description']121 if 'genusTypeId' in self.data():122 form.set_genus_type(Type(self.data()['genusTypeId']))123 new_log = utilities.convert_dl_object(finalize_method(form))124 return new_log125 except Exception as ex:126 utilities.handle_exceptions(ex)127class LogEntriesList(utilities.BaseClass):128 """129 Get or add log entry130 api/v2/logging/logs/<log_id>/logentries/131 GET, POST132 GET to view current log entries133 POST to create a new log entry134 Note that for RESTful calls, you need to set the request header135 'content-type' to 'application/json'136 Example (note the use of double quotes!!):137 {"data" : "<JSON string blob, or whatever text blob you want>"}138 """139 @utilities.format_response140 def GET(self, log_id):141 try:142 logm = logutils.get_logging_manager()143 log = logm.get_log(utilities.clean_id(log_id))144 entries = log.get_log_entries()145 data = utilities.extract_items(entries)146 return data147 except Exception as ex:148 utilities.handle_exceptions(ex)149 @utilities.format_response150 def POST(self, log_id):151 try:152 utilities.verify_keys_present(self.data(), ['data'])153 logm = logutils.get_logging_manager()154 log = logm.get_log(utilities.clean_id(log_id))155 form = log.get_log_entry_form_for_create([TEXT_BLOB_RECORD_TYPE])156 if isinstance(self.data()['data'], dict):157 blob = json.dumps(self.data()['data'])158 else:159 blob = str(self.data()['data'])160 form.set_text(blob)161 entry = log.create_log_entry(form)162 return utilities.convert_dl_object(entry)163 except Exception as ex:164 utilities.handle_exceptions(ex)165class LogEntryDetails(utilities.BaseClass):166 """167 Get log entry details168 api/v2/logging/logs/<log_id>/logentries/<entry_id>/169 GET, PUT, DELETE170 PUT to modify an existing log entry (name, score / grade, etc.).171 Include only the changed parameters.172 DELETE to remove the log entry.173 Note that for RESTful calls, you need to set the request header174 'content-type' to 'application/json'175 Example (note the use of double quotes!!):176 {"data" : "foo"}177 """178 @utilities.format_response179 def DELETE(self, log_id, entry_id):180 try:181 logm = logutils.get_logging_manager()182 log = logm.get_log(utilities.clean_id(log_id))183 log.delete_log_entry(utilities.clean_id(entry_id))184 return utilities.success()185 except Exception as ex:186 utilities.handle_exceptions(ex)187 @utilities.format_response188 def GET(self, log_id, entry_id):189 try:190 logm = logutils.get_logging_manager()191 lels = logm.get_log_entry_lookup_session(proxy=logm._proxy)192 lels.use_federated_log_view()193 entry = lels.get_log_entry(utilities.clean_id(entry_id))194 entry_map = entry.object_map195 return entry_map196 except Exception as ex:197 utilities.handle_exceptions(ex)198 @utilities.format_response199 def PUT(self, log_id, entry_id):200 try:201 utilities.verify_at_least_one_key_present(self.data(),202 ['data'])203 logm = logutils.get_logging_manager()204 log = logm.get_log(utilities.clean_id(log_id))205 form = log.get_log_entry_form_for_update(utilities.clean_id(entry_id))206 if 'data' in self.data():207 if isinstance(self.data()['data'], dict):208 blob = json.dumps(self.data()['data'])209 else:210 blob = str(self.data()['data'])211 form.set_text(blob)212 log.update_log_entry(form)213 entry = log.get_log_entry(utilities.clean_id(entry_id))214 return utilities.convert_dl_object(entry)215 except Exception as ex:216 utilities.handle_exceptions(ex)217class GenericLogEntries(utilities.BaseClass):218 def _get_log(self):219 logm = logutils.get_logging_manager()220 logs = logm.get_logs()221 default_log = None222 for log in logs:223 if str(log.genus_type) == DEFAULT_LOG_GENUS_TYPE:224 default_log = log225 break226 if default_log is None:227 form = logm.get_log_form_for_create([])228 form.set_genus_type(Type(DEFAULT_LOG_GENUS_TYPE))229 form.display_name = 'Default CLIx QBank log'230 form.description = 'For logging info from unplatform and tools, which do not know about catalog IDs'231 default_log = logm.create_log(form)232 return default_log233 @utilities.format_response...

Full Screen

Full Screen

setup_job_unittest.py

Source:setup_job_unittest.py Github

copy

Full Screen

...96 dummy_configure_logging)97 real_get_logging_manager = logging_manager.get_logging_manager98 def get_logging_manager_no_fds(manage_stdout_and_stderr=False,99 redirect_fds=False):100 return real_get_logging_manager(manage_stdout_and_stderr, False)101 self.god.stub_with(logging_manager, 'get_logging_manager',102 get_logging_manager_no_fds)103 # stub out some stuff104 self.god.stub_function(os.path, 'exists')105 self.god.stub_function(os.path, 'isdir')106 self.god.stub_function(os, 'makedirs')107 self.god.stub_function(os, 'mkdir')108 self.god.stub_function(os, 'remove')109 self.god.stub_function(shutil, 'rmtree')110 self.god.stub_function(shutil, 'copyfile')111 self.god.stub_function(setup_job, 'open')112 self.god.stub_function(utils, 'system')113 self.god.stub_class_method(job.base_client_job,114 '_cleanup_debugdir_files')...

Full Screen

Full Screen

logging_utilities.py

Source:logging_utilities.py Github

copy

Full Screen

1import web2from dlkit.runtime import PROXY_SESSION, RUNTIME3from dlkit.runtime.proxy_example import SimpleRequest4def get_logging_manager():5 condition = PROXY_SESSION.get_proxy_condition()6 dummy_request = SimpleRequest(username=web.ctx.env.get('HTTP_X_API_PROXY', 'student@tiss.edu'),7 authenticated=True)8 condition.set_http_request(dummy_request)9 proxy = PROXY_SESSION.get_proxy(condition)10 return RUNTIME.get_service_manager('LOGGING',...

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