Skip to content

Commit 67e0876

Browse files
committed
Initial commit of configIOC.py
1 parent 97d41f0 commit 67e0876

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

configIOC.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/usr/bin/env python3
2+
#
3+
# A script to configure an xxx IOC in the style of makeIOC.sh
4+
#
5+
6+
import os
7+
import sys
8+
import argparse
9+
10+
11+
def remove_file(path):
12+
if os.path.isfile(path):
13+
#!os.system("git rm -f {}".format(path))
14+
print("git rm -f {}".format(path))
15+
else:
16+
print("{} is not a file".format(path))
17+
18+
def remove_dir(path, save=None):
19+
deleteEntireDir = True
20+
21+
if save != None:
22+
for fp in save:
23+
if path == os.path.dirname(fp):
24+
deleteEntireDir = False
25+
break
26+
27+
if deleteEntireDir:
28+
if os.path.isdir(path):
29+
#!os.system("git rm -rf {}".format(path))
30+
print("git rm -rf {}".format(path))
31+
else:
32+
print("{} is not a dir".format(path))
33+
else:
34+
for fn in os.listdir(path):
35+
fp = "{}/{}".format(path, fn)
36+
if fp in save:
37+
print("saving {}".format(fp))
38+
else:
39+
remove_file(fp)
40+
41+
def deleteCommonFiles(iocName):
42+
filesToDelete = ['LICENSE', 'README', 'README.md', 'start_putrecorder',
43+
'iocBoot/accessSecurity.acf',
44+
'iocBoot/ioc{}/README'.format(iocName),
45+
'iocBoot/ioc{}/SGMenu.req'.format(iocName),
46+
'iocBoot/ioc{}/bootParms'.format(iocName),
47+
'iocBoot/ioc{}/softioc/in-screen.sh'.format(iocName),
48+
'iocBoot/ioc{}/softioc/run'.format(iocName),
49+
'iocBoot/ioc{}/st.cmd.Cygwin'.format(iocName),
50+
'{}App/Db/Security_Control.db'.format(iocName),
51+
'{}App/Db/Security_Control_settings.req'.format(iocName),
52+
'{}App/Db/streamExample.db'.format(iocName),
53+
]
54+
55+
dirsToDelete = ['documentation',
56+
'iocBoot/ioc{}/examples'.format(iocName),
57+
'iocBoot/ioc{}/substitutions'.format(iocName),
58+
'{}App/op/bob/autoconvert'.format(iocName),
59+
'{}App/op/edl/autoconvert'.format(iocName),
60+
'{}App/op/opi'.format(iocName),
61+
'{}App/op/python'.format(iocName),
62+
'{}App/op/burt'.format(iocName),
63+
]
64+
65+
filesToKeep = ['iocBoot/ioc{}/substitutions/motor.substitutions'.format(iocName),
66+
'iocBoot/ioc{}/substitutions/motorSim.substitutions'.format(iocName),
67+
'iocBoot/ioc{}/substitutions/softMotor.substitutions'.format(iocName),
68+
69+
]
70+
71+
for fp in filesToDelete:
72+
remove_file(fp)
73+
74+
for dp in dirsToDelete:
75+
remove_dir(dp, filesToKeep)
76+
77+
def main(options):
78+
print(options)
79+
80+
pwd = os.getcwd()
81+
82+
# Assume the following:
83+
# 1. The name of the IOC's top-level directory is the name of the IOC
84+
iocName = os.path.basename(pwd)
85+
86+
deleteCommonFiles(iocName)
87+
88+
89+
if __name__ == '__main__':
90+
parser = argparse.ArgumentParser("configIOC.py")
91+
92+
parser.add_argument('os', choices=('linux', 'vxWorks', 'windows'))
93+
94+
options = parser.parse_args(sys.argv[1:])
95+
96+
main(options)

0 commit comments

Comments
 (0)