--- /dev/null
+""" Copyright (c) 2019 AT&T Intellectual Property. #\r
+# #\r
+# Licensed under the Apache License, Version 2.0 (the "License"); #\r
+# you may not use this file except in compliance with the License. #\r
+# You may obtain a copy of the License at #\r
+# #\r
+# http://www.apache.org/licenses/LICENSE-2.0 #\r
+# #\r
+# Unless required by applicable law or agreed to in writing, software #\r
+# distributed under the License is distributed on an "AS IS" BASIS, #\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #\r
+# See the License for the specific language governing permissions and #\r
+# limitations under the License. #\r
+#############################################################################"""\r
+\r
+\r
+import os\r
+import datetime\r
+import json\r
+\r
+\r
+def unix_time_millis(dt):\r
+ epoch = datetime.datetime.utcfromtimestamp(0)\r
+ return (dt - epoch).total_seconds() * 1000.0\r
+\r
+\r
+def zip_dir(path, zip_handle):\r
+ for root, dirs, files in os.walk(path):\r
+ for f in files:\r
+ zip_handle.write(os.path.join(root, f))\r
+\r
+\r
+def try_get_json_value(key, data):\r
+ if key not in data:\r
+ raise KeyError('The key {key} is not in {data}.'\r
+ .format(key=key, data=json.dumps(data)))\r
+\r
+ return data[key]\r
+\r
+\r
+def resolve_robot_status_code(code):\r
+ resolved_message = 'Invalid robot status code.'\r
+\r
+ if code == 0:\r
+ resolved_message = 'All critical tests passed.'\r
+ elif 0 <= code <= 249:\r
+ resolved_message = '{numTestsFailed} test(s) failed.'.format(numTestsFailed=code)\r
+ elif code == 250:\r
+ resolved_message = '250 or more critical failures.'\r
+ elif code == 251:\r
+ resolved_message = 'Help or version information printed.'\r
+ elif code == 252:\r
+ resolved_message = 'Invalid test data or command line options.'\r
+ elif code == 253:\r
+ resolved_message = 'Test execution stopped by user.'\r
+ elif code == 255:\r
+ resolved_message = 'Unexpected internal error.'\r
+\r
+ return resolved_message\r
+\r
+\r
+\r