Skip to content

Commit c3ad080

Browse files
committedJul 30, 2020
move project code names to a separate shared projcode module and revert absolute imports from last commit until we figure out how to make them work with python 2 and our project layout
git-svn-id: svn+ssh://svn.code.sf.net/p/migrid/code/trunk@4894 b75ad72c-e7d7-11dd-a971-7dbc132099af
1 parent 59da721 commit c3ad080

File tree

6 files changed

+135
-93
lines changed

6 files changed

+135
-93
lines changed
 

‎makerelease.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
33
#
4+
# --- BEGIN_HEADER ---
5+
#
46
# makerelease - a simple helper to create a MiG project code release.
5-
# Copyright (C) 2009 Jonas Bardino
7+
# Copyright (C) 2009-2020 Jonas Bardino
68
#
79
# This file is part of MiG.
810
#
@@ -18,9 +20,14 @@
1820
#
1921
# You should have received a copy of the GNU General Public License
2022
# along with this program; if not, write to the Free Software
21-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24+
# 02110-1301, USA.
25+
#
26+
# --- END_HEADER ---
27+
#
2228

2329
"""Pack relevant parts of the code in a versioned tarball"""
30+
2431
from __future__ import print_function
2532

2633
import os
@@ -29,7 +36,8 @@
2936

3037
if len(sys.argv) < 2:
3138
print('Usage: %s VERSION TARGET' % sys.argv[0])
32-
print('Make a release tarball of all code in TARGET and stamp it as VERSION')
39+
print(
40+
'Make a release tarball of all code in TARGET and stamp it as VERSION')
3341
sys.exit(1)
3442

3543
version = sys.argv[1]
@@ -60,10 +68,9 @@
6068
if name.startswith(tar_path):
6169
continue
6270
path = os.path.normpath(os.path.join(root, name))
63-
rel_path = path.replace(target+os.sep, '')
71+
rel_path = path.replace(target + os.sep, '')
6472
archive_path = os.path.join(archive_base, rel_path)
6573
print('Adding %s' % archive_path)
6674
tar_ball.add(rel_path, archive_path, recursive=False)
6775
tar_ball.close()
6876
print('Wrote release of %s in %s' % (target, tar_path))
69-

‎mig/addheader.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# --- BEGIN_HEADER ---
55
#
66
# addheader - add license header to all code modules.
7-
# Copyright (C) 2009-2017 Jonas Bardino
7+
# Copyright (C) 2009-2020 Jonas Bardino
88
#
99
# This file is part of MiG.
1010
#
@@ -28,14 +28,13 @@
2828

2929
"""Search code tree and add the required header to all python modules"""
3030
from __future__ import print_function
31-
from __future__ import absolute_import
3231

3332
import datetime
3433
import fnmatch
3534
import os
3635
import sys
3736

38-
from .codegrep import py_code_files, sh_code_files, js_code_files
37+
from shared.projcode import py_code_files, sh_code_files, js_code_files
3938

4039
# Modify these to fit actual project
4140
proj_vars = {}
@@ -70,17 +69,18 @@
7069
# it under the terms of the GNU General Public License as published by
7170
# the Free Software Foundation; either version 2 of the License, or
7271
# (at your option) any later version.
73-
#
72+
#
7473
# %(project_name)s is distributed in the hope that it will be useful,
7574
# but WITHOUT ANY WARRANTY; without even the implied warranty of
7675
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7776
# GNU General Public License for more details.
78-
#
77+
#
7978
# You should have received a copy of the GNU General Public License
8079
# along with this program; if not, write to the Free Software
8180
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
8281
# USA."""
8382

83+
8484
def check_header(path, var_dict, preamble_size=4096):
8585
"""Check if path already has a credible license header. Only looks inside
8686
the first preamble_size bytes of the file.
@@ -89,11 +89,12 @@ def check_header(path, var_dict, preamble_size=4096):
8989
module_preamble = module_fd.read(4096)
9090
module_fd.close()
9191
if begin_marker in module_preamble or \
92-
proj_vars['authors'] in module_preamble:
92+
proj_vars['authors'] in module_preamble:
9393
return True
9494
else:
9595
return False
96-
96+
97+
9798
def add_header(path, var_dict, explicit_border=True, block_wrap=False):
9899
"""Add the required copyright and license header to module in path.
99100
The optional explicit_border argument can be set to wrap the license
@@ -127,7 +128,7 @@ def add_header(path, var_dict, explicit_border=True, block_wrap=False):
127128
if module_lines and module_lines[0].startswith("#!"):
128129
module_header.append(module_lines[0].strip())
129130
module_lines = module_lines[1:]
130-
131+
131132
if var_dict['module_encoding']:
132133
module_header.append(enc)
133134
if module_lines and module_lines[0].startswith("# -*- coding"):
@@ -149,12 +150,11 @@ def add_header(path, var_dict, explicit_border=True, block_wrap=False):
149150
%s
150151
*/
151152
""" % lic
152-
153+
153154
module_header.append(lic)
154155
module_text = '\n'.join(module_header) % var_dict + '\n'\
155-
+ ''.join(module_lines)
156+
+ ''.join(module_lines)
156157

157-
158158
module_fd = open(path, 'w')
159159
module_fd.write(module_text)
160160
module_fd.close()
@@ -170,7 +170,7 @@ def add_header(path, var_dict, explicit_border=True, block_wrap=False):
170170
for (root, dirs, files) in os.walk(target):
171171

172172
# skip all dot dirs - they are from repos etc and _not_ jobs
173-
173+
174174
if root.find(os.sep + '.') != -1:
175175
continue
176176
for name in files:
@@ -183,11 +183,11 @@ def add_header(path, var_dict, explicit_border=True, block_wrap=False):
183183
needs_block = True
184184
else:
185185
needs_block = False
186-
186+
187187
pattern = os.path.join(mig_code_base, pattern)
188188

189189
# print "Testing %s against %s" % (src_path, pattern)
190-
190+
191191
if src_path == pattern or fnmatch.fnmatch(src_path, pattern):
192192
print('Matched %s against %s' % (src_path, pattern))
193193
proj_vars['module_name'] = name.replace('.py', '')

‎mig/bugweed.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
33
#
4+
# --- BEGIN_HEADER ---
5+
#
46
# bugweed - a simple helper to locate simple error in the project code.
5-
# Copyright (C) 2003-2015 The MiG Project lead by Brian Vinter
7+
# Copyright (C) 2003-2020 The MiG Project lead by Brian Vinter
68
#
79
# This file is part of MiG.
810
#
@@ -18,17 +20,20 @@
1820
#
1921
# You should have received a copy of the GNU General Public License
2022
# along with this program; if not, write to the Free Software
21-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24+
# 02110-1301, USA.
25+
#
26+
# --- END_HEADER ---
27+
#
2228

2329
"""Grep for obvious errors in pylint output for all code"""
2430
from __future__ import print_function
25-
from __future__ import absolute_import
2631

2732
import glob
2833
import sys
2934

30-
from .codegrep import py_code_files
31-
from .shared.safeeval import subprocess_call
35+
from shared.projcode import py_code_files
36+
from shared.safeeval import subprocess_call
3237

3338
if '__main__' == __name__:
3439
if len(sys.argv) != 1:
@@ -44,6 +49,6 @@
4449
print("Bug weeding command: %s" % command)
4550
print("*** Not all lines reported are necessarily errors ***")
4651
print()
47-
#subprocess_call(command, only_sanitized_variables=True)
48-
# NOTE: we use command list to avoid shell requirement
52+
# subprocess_call(command, only_sanitized_variables=True)
53+
# NOTE: we use command list to avoid shell requirement
4954
subprocess_call(command_list)

‎mig/codegrep.py

+11-62
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
33
#
4+
# --- BEGIN_HEADER ---
5+
#
46
# codegrep - a simple helper to locate strings in the project code.
5-
# Copyright (C) 2003-2018 The MiG Project lead by Brian Vinter
7+
# Copyright (C) 2003-2020 The MiG Project lead by Brian Vinter
68
#
79
# This file is part of MiG.
810
#
@@ -18,75 +20,22 @@
1820
#
1921
# You should have received a copy of the GNU General Public License
2022
# along with this program; if not, write to the Free Software
21-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24+
# 02110-1301, USA.
25+
#
26+
# --- END_HEADER ---
27+
#
2228

2329
"""Grep for a regular expression in all code files"""
30+
2431
from __future__ import print_function
25-
from __future__ import absolute_import
2632

2733
import glob
2834
import sys
2935

30-
from .shared.safeeval import subprocess_call
31-
32-
# Ignore backup and dot files in wild card match
33-
plain = '[a-zA-Z0-9]*.py'
34-
py_code_files = [
35-
'%s' % plain,
36-
'cgi-bin/%s' % plain,
37-
'cgi-sid/%s' % plain,
38-
'wsgi-bin/%s' % plain,
39-
'install/%s' % plain,
40-
'migfs-fuse/%s' % plain,
41-
'resource/bin/%s' % plain,
42-
'resource/image-scripts/%s' % plain,
43-
'resource/keepalive-scripts/%s' % plain,
44-
'server/%s' % plain,
45-
'shared/%s' % plain,
46-
'shared/functionality/%s' % plain,
47-
'shared/distos/%s' % plain,
48-
'simulation/%s' % plain,
49-
'user/%s' % plain,
50-
'vm-proxy/%s' % plain,
51-
'webserver/%s' % plain,
52-
'wsgi-bin/%s' % plain,
53-
]
54-
py_code_files += ['cgi-sid/%s' % name for name in ['requestnewjob',
55-
'putrespgid']]
36+
from shared.projcode import code_files
37+
from shared.safeeval import subprocess_call
5638

57-
py_code_files += ['cgi-bin/%s' % name for name in [
58-
'listdir',
59-
'mkdir',
60-
'put',
61-
'remove',
62-
'rename',
63-
'rmdir',
64-
'stat',
65-
'walk',
66-
'getrespgid',
67-
]]
68-
sh_code_files = [
69-
'resource/frontend_script.sh',
70-
'resource/master_node_script.sh',
71-
'resource/leader_node_script.sh',
72-
'resource/dummy_node_script.sh',
73-
]
74-
js_code_files = [
75-
'images/js/jquery.ajaxhelpers.js',
76-
'images/js/jquery.confirm.js',
77-
'images/js/jquery.filemanager.js',
78-
'images/js/jquery.jobmanager.js',
79-
'images/js/jquery.migtools.js',
80-
'images/js/jquery.prettyprint.js',
81-
'images/js/preview-caman.js',
82-
'images/js/preview.js',
83-
'images/js/preview-paraview.js',
84-
'assets/js/V2/ui-dynamic.js',
85-
'assets/js/V3/ui-dynamic.js',
86-
'assets/js/V3/ui-global.js',
87-
'assets/js/V3/ui-extra.js',
88-
]
89-
code_files = py_code_files + sh_code_files + js_code_files
9039

9140
if '__main__' == __name__:
9241
if len(sys.argv) < 2:

‎mig/edpickle.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
3-
43
#
54
# --- BEGIN_HEADER ---
65
#
7-
#
86
# edpickle - a simple pickled object editor.
9-
# Copyright (C) 2003-2018 The MiG Project lead by Brian Vinter
7+
# Copyright (C) 2003-2020 The MiG Project lead by Brian Vinter
108
#
119
# This file is part of MiG.
1210
#
@@ -29,13 +27,13 @@
2927
#
3028

3129
"""Edit pickled objects on disk"""
30+
3231
from __future__ import print_function
33-
from __future__ import absolute_import
3432

3533
import os
3634
import sys
3735

38-
from .shared.serial import pickle
36+
from shared.serial import pickle
3937

4038

4139
if len(sys.argv) < 2:

‎mig/shared/projcode.py

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/usr/bin/python
2+
# -*- coding: utf-8 -*-
3+
#
4+
# projcode - simple helpers for transforming or searching project code
5+
# Copyright (C) 2003-2020 The MiG Project lead by Brian Vinter
6+
#
7+
# This file is part of MiG.
8+
#
9+
# MiG is free software: you can redistribute it and/or modify
10+
# it under the terms of the GNU General Public License as published by
11+
# the Free Software Foundation; either version 2 of the License, or
12+
# (at your option) any later version.
13+
#
14+
# MiG is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU General Public License
20+
# along with this program; if not, write to the Free Software
21+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22+
# 02110-1301, USA.
23+
24+
"""Helpers to transform or search project code files"""
25+
26+
# Ignore backup and dot files in wild card match
27+
plain = '[a-zA-Z0-9]*.py'
28+
py_code_files = [
29+
'%s' % plain,
30+
'cgi-bin/%s' % plain,
31+
'cgi-sid/%s' % plain,
32+
'wsgi-bin/%s' % plain,
33+
'install/%s' % plain,
34+
'migfs-fuse/%s' % plain,
35+
'resource/bin/%s' % plain,
36+
'resource/image-scripts/%s' % plain,
37+
'resource/keepalive-scripts/%s' % plain,
38+
'server/%s' % plain,
39+
'shared/%s' % plain,
40+
'shared/functionality/%s' % plain,
41+
'shared/distos/%s' % plain,
42+
'simulation/%s' % plain,
43+
'user/%s' % plain,
44+
'vm-proxy/%s' % plain,
45+
'webserver/%s' % plain,
46+
'wsgi-bin/%s' % plain,
47+
]
48+
py_code_files += ['cgi-sid/%s' % name for name in ['requestnewjob',
49+
'putrespgid']]
50+
51+
py_code_files += ['cgi-bin/%s' % name for name in [
52+
'listdir',
53+
'mkdir',
54+
'put',
55+
'remove',
56+
'rename',
57+
'rmdir',
58+
'stat',
59+
'walk',
60+
'getrespgid',
61+
]]
62+
sh_code_files = [
63+
'resource/frontend_script.sh',
64+
'resource/master_node_script.sh',
65+
'resource/leader_node_script.sh',
66+
'resource/dummy_node_script.sh',
67+
]
68+
js_code_files = [
69+
'images/js/jquery.ajaxhelpers.js',
70+
'images/js/jquery.confirm.js',
71+
'images/js/jquery.filemanager.js',
72+
'images/js/jquery.jobmanager.js',
73+
'images/js/jquery.migtools.js',
74+
'images/js/jquery.prettyprint.js',
75+
'images/js/preview-caman.js',
76+
'images/js/preview.js',
77+
'images/js/preview-paraview.js',
78+
'assets/js/V2/ui-dynamic.js',
79+
'assets/js/V3/ui-dynamic.js',
80+
'assets/js/V3/ui-global.js',
81+
'assets/js/V3/ui-extra.js',
82+
]
83+
code_files = py_code_files + sh_code_files + js_code_files

0 commit comments

Comments
 (0)
Please sign in to comment.