diff options
Diffstat (limited to 'scripts/lib/resulttool/resultsutils.py')
-rw-r--r-- | scripts/lib/resulttool/resultsutils.py | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/scripts/lib/resulttool/resultsutils.py b/scripts/lib/resulttool/resultsutils.py deleted file mode 100644 index 368786922c..0000000000 --- a/scripts/lib/resulttool/resultsutils.py +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
1 | # test result tool - utilities | ||
2 | # | ||
3 | # Copyright (c) 2019, Intel Corporation. | ||
4 | # | ||
5 | # This program is free software; you can redistribute it and/or modify it | ||
6 | # under the terms and conditions of the GNU General Public License, | ||
7 | # version 2, as published by the Free Software Foundation. | ||
8 | # | ||
9 | # This program is distributed in the hope it will be useful, but WITHOUT | ||
10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | # more details. | ||
13 | # | ||
14 | import os | ||
15 | import json | ||
16 | import scriptpath | ||
17 | scriptpath.add_oe_lib_path() | ||
18 | from oeqa.utils.git import GitRepo, GitError | ||
19 | |||
20 | def load_json_file(file): | ||
21 | with open(file, "r") as f: | ||
22 | return json.load(f) | ||
23 | |||
24 | def dump_json_data(write_dir, file_name, json_data): | ||
25 | file_content = json.dumps(json_data, sort_keys=True, indent=4) | ||
26 | file_path = os.path.join(write_dir, file_name) | ||
27 | with open(file_path, 'w') as the_file: | ||
28 | the_file.write(file_content) | ||
29 | |||
30 | def get_dict_value(logger, dict, key): | ||
31 | try: | ||
32 | return dict[key] | ||
33 | except KeyError: | ||
34 | if logger: | ||
35 | logger.debug('Faced KeyError exception: dict=%s: key=%s' % (dict, key)) | ||
36 | return None | ||
37 | except TypeError: | ||
38 | if logger: | ||
39 | logger.debug('Faced TypeError exception: dict=%s: key=%s' % (dict, key)) | ||
40 | return None | ||
41 | |||
42 | def pop_dict_element(logger, dict, key): | ||
43 | try: | ||
44 | dict.pop(key) | ||
45 | except KeyError: | ||
46 | if logger: | ||
47 | logger.debug('Faced KeyError exception: dict=%s: key=%s' % (dict, key)) | ||
48 | except AttributeError: | ||
49 | if logger: | ||
50 | logger.debug('Faced AttributeError exception: dict=%s: key=%s' % (dict, key)) | ||
51 | |||
52 | def checkout_git_dir(git_dir, git_branch): | ||
53 | try: | ||
54 | repo = GitRepo(git_dir, is_topdir=True) | ||
55 | repo.run_cmd('checkout %s' % git_branch) | ||
56 | return True | ||
57 | except GitError: | ||
58 | return False | ||
59 | |||
60 | def get_directory_files(source_dir, excludes, file): | ||
61 | files_in_dir = [] | ||
62 | for root, dirs, files in os.walk(source_dir, topdown=True): | ||
63 | [dirs.remove(d) for d in list(dirs) if d in excludes] | ||
64 | for name in files: | ||
65 | if name == file: | ||
66 | files_in_dir.append(os.path.join(root, name)) | ||
67 | return files_in_dir \ No newline at end of file | ||