-
Notifications
You must be signed in to change notification settings - Fork 0
/
rename_iso_cd.py
75 lines (59 loc) · 2.64 KB
/
rename_iso_cd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/python2
# -*- coding: utf-8 -*-
# rename_iso_cd.py: rename the cd image and move it to the iso images dir
# Copyright (C) 2016 Pablo De Nápoli <[email protected]>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Dependencies: svn
from __future__ import print_function
import argparse
import json
import os
import re
import subprocess
if __name__ == '__main__':
# We parse the command-line arguments
parser = \
argparse.ArgumentParser(description='Checkout the ReactOS sources.'
)
parser.add_argument('--revision', dest='revision',
help='for which revision? [default=current revision]'
)
parser.add_argument('--config', dest='config_file_name',
help='configuration file to read',
default='config.json')
# parser.add_argument('--compile', action='store_const', const=True,
# help='Compile React OS from the sources')
args = parser.parse_args()
# We use a configuration file with json format for several configuration parameters.
if os.path.isfile(args.config_file_name):
try:
config = json.load(open(args.config_file_name))
except ValueError:
print('Error parsing the configuration file',
args.config_file_name)
sys.exit(3)
else:
print('Configuration file', args.config_file_name,
' does not exist.')
sys.exit(4)
build_dir = os.path.abspath(config['reactos_build_dir'])
src_dir = os.path.abspath(config['reactos_src_dir'])
iso_images_dir = os.path.abspath(config['iso_images_dir'])
p = subprocess.Popen(['svnversion', src_dir + '/reactos'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p.wait()
m = re.match(r'(|\d+M?S?):?(\d+)(M?)S?', p.stdout.read())
rev = int(m.group(2))
new_name = 'bootcd-compiled-' + str(rev) + '.iso'
print(new_name)
os.rename(build_dir + '/reactos/bootcd.iso', iso_images_dir + '/'
+ new_name)