1 """ Copyright (c) 2019 AT&T Intellectual Property. #
\r
3 # Licensed under the Apache License, Version 2.0 (the "License"); #
\r
4 # you may not use this file except in compliance with the License. #
\r
5 # You may obtain a copy of the License at #
\r
7 # http://www.apache.org/licenses/LICENSE-2.0 #
\r
9 # Unless required by applicable law or agreed to in writing, software #
\r
10 # distributed under the License is distributed on an "AS IS" BASIS, #
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
\r
12 # See the License for the specific language governing permissions and #
\r
13 # limitations under the License. #
\r
14 #############################################################################"""
\r
22 def unix_time_millis(dt):
\r
23 epoch = datetime.datetime.utcfromtimestamp(0)
\r
24 return (dt - epoch).total_seconds() * 1000.0
\r
27 def zip_dir(path, zip_handle):
\r
28 for root, dirs, files in os.walk(path):
\r
30 zip_handle.write(os.path.join(root, f))
\r
33 def try_get_json_value(key, data):
\r
35 raise KeyError('The key {key} is not in {data}.'
\r
36 .format(key=key, data=json.dumps(data)))
\r
41 def resolve_robot_status_code(code):
\r
42 resolved_message = 'Invalid robot status code.'
\r
45 resolved_message = 'All critical tests passed.'
\r
46 elif 0 <= code <= 249:
\r
47 resolved_message = '{numTestsFailed} test(s) failed.'.format(numTestsFailed=code)
\r
49 resolved_message = '250 or more critical failures.'
\r
51 resolved_message = 'Help or version information printed.'
\r
53 resolved_message = 'Invalid test data or command line options.'
\r
55 resolved_message = 'Test execution stopped by user.'
\r
57 resolved_message = 'Unexpected internal error.'
\r
59 return resolved_message
\r