Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
e3-require
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ESS EPICS Environment
wrappers
e3-require
Commits
24e10d69
Commit
24e10d69
authored
20 years ago
by
maden
Browse files
Options
Downloads
Patches
Plain Diff
Add time-out
parent
50ed4072
No related branches found
No related tags found
1 merge request
!7
Submodule merge
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
App/scripts/call_ioc_ins
+108
-63
108 additions, 63 deletions
App/scripts/call_ioc_ins
with
108 additions
and
63 deletions
App/scripts/call_ioc_ins
+
108
−
63
View file @
24e10d69
#! /usr/bin/env python
#! /usr/bin/env python
#
#
# $Source: /cvs/G/DRV/misc/App/scripts/call_ioc_ins,v $
# $Source: /cvs/G/DRV/misc/App/scripts/call_ioc_ins,v $
# $Revision: 1.
4
$ $Date: 2004/07/26
09:33:25
$
# $Revision: 1.
5
$ $Date: 2004/07/26
11:39:38
$
'''
'''
Insert boot information about IOCs into the ssrm_public Oracle database.
Insert boot information about IOCs into the ssrm_public Oracle database.
Usage:
Usage:
-----
-----
call_ioc_ins [--help] [-v]
\\
call_ioc_ins [--help] [-v]
[--debug] [-t=<secs>]
\\
<system> <ipadd> <procnum>
\\
<system> <ipadd> <procnum>
\\
<device> <bootpc> <slsbase>
\\
<device> <bootpc> <slsbase>
\\
<bootfile> <script> <vxworks>
\\
<bootfile> <script> <vxworks>
\\
<epicsver> <vxworksver> <ethaddr>
<epicsver> <vxworksver> <ethaddr>
Default time-out (-t) = 10 secs.
Example:
Example:
-------
-------
call_ioc_ins X04SA-VME-PLD 172.19.151.29 0
\\
call_ioc_ins X04SA-VME-PLD 172.19.151.29 0
\\
...
@@ -23,26 +25,20 @@
...
@@ -23,26 +25,20 @@
'''
'''
#--------------------------------------------------------------------
#--------------------------------------------------------------------
import
sys
import
os
,
sys
import
o
s
import
command
s
import
urllib
import
urllib
import
string
import
string
import
getopt
import
getopt
import
time
import
time
import
signal
#--------------------------------------------------------------------
#--------------------------------------------------------------------
import
sys
import
os
import
urllib
#---------------------------------------------------------------------------
def
showVersion
():
def
showVersion
():
# ===========
# ===========
'''
'''
$Source: /cvs/G/DRV/misc/App/scripts/call_ioc_ins,v $
$Source: /cvs/G/DRV/misc/App/scripts/call_ioc_ins,v $
$Revision: 1.
4
$ $Date: 2004/07/26
09:33:25
$
$Revision: 1.
5
$ $Date: 2004/07/26
11:39:38
$
Installed Location: $SLSBASE/sls/bin
Installed Location: $SLSBASE/sls/bin
'''
'''
print
showVersion
.
__doc__
print
showVersion
.
__doc__
...
@@ -59,50 +55,101 @@ def showUsage ():
...
@@ -59,50 +55,101 @@ def showUsage ():
# The program starts here!
# The program starts here!
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
try
:
sys
.
stderr
=
sys
.
stdout
sys
.
stderr
=
sys
.
stdout
#
#
# Analyse the options
# Analyse the options
#
#
force
=
0
debug
=
0
(
opts
,
items
)
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"
h?vf
"
,
\
timeout
=
10
(
"
help
"
,
"
nocc
"
))
try
:
(
opts
,
items
)
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"
h?vt:
"
,
\
(
"
help
"
,
"
debug
"
))
for
opt
in
opts
:
for
opt
in
opts
:
if
opt
[
0
]
==
"
-h
"
:
raise
"
Help
"
if
opt
[
0
]
==
"
-h
"
:
raise
"
Help
"
if
opt
[
0
]
==
"
-?
"
:
raise
"
Help
"
if
opt
[
0
]
==
"
-?
"
:
raise
"
Help
"
if
opt
[
0
]
==
"
--help
"
:
raise
"
Help
"
if
opt
[
0
]
==
"
--help
"
:
raise
"
Help
"
if
opt
[
0
]
==
"
-v
"
:
raise
"
Version
"
if
opt
[
0
]
==
"
-v
"
:
raise
"
Version
"
if
opt
[
0
]
==
"
-f
"
:
force
=
1
if
opt
[
0
]
==
"
-t
"
:
timeout
=
int
(
opt
[
1
])
if
timeout
<=
0
:
print
"
\a
Time-out must be a positive integer.
"
raise
#endif
#endif
if
opt
[
0
]
==
"
--debug
"
:
debug
=
1
#endfor
#endfor
#######################################
except
"
Help
"
:
####
showUsage
()
#### Network problems --- disable!!!
sys
.
exit
(
0
)
####
except
"
Version
"
:
if
not
force
:
sys
.
exit
(
0
)
showVersion
()
####
sys
.
exit
(
0
)
#######################################
except
:
if
len
(
items
)
!=
12
:
print
"
\a
Bad option. Specify
\"
-h
\"
for help.
"
print
"
Twelve arguments are needed, not %d
"
%
len
(
items
)
sys
.
exit
(
1
)
#endtry
#######################################
# Make sure we are running at least python level 2.
# CaChannel seems to give troubles otherwise!
#
if
sys
.
version
[
0
:
1
]
==
"
1
"
:
if
debug
:
print
"
The default python version is
"
,
string
.
split
(
sys
.
version
)[
0
]
print
"
Trying to find a version of python2 ...
"
#endif
python2
=
commands
.
getoutput
(
"
type -p python2
"
)
if
python2
==
""
:
print
"
\n\a
The default python version is
"
,
sys
.
version
print
"
and this script needs python level 2 or higher.
"
print
"
Python level 2 cannot be found.
"
sys
.
exit
(
1
)
sys
.
exit
(
1
)
#endif
#endif
if
debug
:
print
"
Switching to %s ...
"
%
python2
sys
.
argv
.
insert
(
0
,
python2
)
os
.
execv
(
python2
,
sys
.
argv
)
#endif
if
sys
.
version
[
0
:
1
]
==
"
1
"
:
print
"
\n\a
The loading of a higher level of python seems to have failed!
"
sys
.
exit
(
1
)
#endif
#######################################
if
debug
:
print
"
Time-out = %d secs
"
%
timeout
print
"
Arguments:
"
for
i
in
range
(
len
(
items
)):
print
"
"
,
items
[
i
]
#endfor
#endif
args
=
{}
if
len
(
items
)
!=
12
:
args
[
"
SYSTEM
"
]
=
items
[
0
]
print
"
Twelve arguments are needed, not %d
"
%
len
(
items
)
args
[
"
IPADDR
"
]
=
items
[
1
]
sys
.
exit
(
1
)
args
[
"
PROCNUM
"
]
=
items
[
2
]
#endif
args
[
"
DEVICE
"
]
=
items
[
3
]
args
[
"
BOOTPC
"
]
=
items
[
4
]
args
=
{}
args
[
"
SLSBASE
"
]
=
items
[
5
]
args
[
"
SYSTEM
"
]
=
items
[
0
]
args
[
"
BOOTFILE
"
]
=
items
[
6
]
args
[
"
IPADDR
"
]
=
items
[
1
]
args
[
"
SCRIPT
"
]
=
items
[
7
]
args
[
"
PROCNUM
"
]
=
items
[
2
]
args
[
"
VXWORKS
"
]
=
items
[
8
]
args
[
"
DEVICE
"
]
=
items
[
3
]
args
[
"
EPICSVER
"
]
=
items
[
9
]
args
[
"
BOOTPC
"
]
=
items
[
4
]
args
[
"
VXWORKSVER
"
]
=
items
[
10
]
args
[
"
SLSBASE
"
]
=
items
[
5
]
args
[
"
ETHADDR
"
]
=
items
[
11
]
args
[
"
BOOTFILE
"
]
=
items
[
6
]
args
[
"
SCRIPT
"
]
=
items
[
7
]
encArgs
=
urllib
.
urlencode
(
args
)
args
[
"
VXWORKS
"
]
=
items
[
8
]
args
[
"
EPICSVER
"
]
=
items
[
9
]
url
=
"
http://pc4860.psi.ch/testplan/IOC_INFOS/ioc_boot_ins.php?
"
+
encArgs
args
[
"
VXWORKSVER
"
]
=
items
[
10
]
args
[
"
ETHADDR
"
]
=
items
[
11
]
encArgs
=
urllib
.
urlencode
(
args
)
url
=
"
http://pc4860.psi.ch/testplan/IOC_INFOS/ioc_boot_ins.php?
"
+
encArgs
if
debug
:
print
"
The URL is
\"
%s
\"
"
%
url
print
"
Forking child process to do the work ...
"
#endif
childPID
=
os
.
fork
()
if
childPID
==
0
:
try
:
try
:
ufo
=
urllib
.
urlopen
(
url
)
# Query the database
ufo
=
urllib
.
urlopen
(
url
)
# Query the database
lines
=
ufo
.
readlines
()
# Get the result
lines
=
ufo
.
readlines
()
# Get the result
...
@@ -111,26 +158,21 @@ if __name__ == "__main__":
...
@@ -111,26 +158,21 @@ if __name__ == "__main__":
print
"
\a
Error inserting data into database!
"
print
"
\a
Error inserting data into database!
"
raise
raise
#endtry
#endtry
except
getopt
.
error
:
print
"
Bad option. Specify
\"
-h
\"
for help.
"
sys
.
exit
(
1
)
except
"
Help
"
:
showUsage
()
sys
.
exit
(
0
)
sys
.
exit
(
0
)
else
:
except
"
Version
"
:
if
debug
:
print
"
Child
'
s pid = %d
"
%
childPID
showVersion
()
for
i
in
range
(
int
(
timeout
)):
sys
.
exit
(
0
)
time
.
sleep
(
1
)
(
pid
,
status
)
=
os
.
waitpid
(
childPID
,
os
.
WNOHANG
)
except
"
NoArgs
"
:
if
debug
:
print
"
waitpid return status = (%d, %d)
"
%
(
pid
,
status
)
print
"
\a
You must specify a search pattern!
"
if
pid
==
childPID
:
sys
.
exit
(
1
)
if
debug
:
print
"
Child has exited.
"
sys
.
exit
(
0
)
#endtry
#endif
#endfor
sys
.
exit
(
0
)
if
debug
:
print
"
Timeout.
"
os
.
kill
(
childPID
,
signal
.
SIGKILL
)
#endif
#endif
#endif
#--------------------------------------------------#
#--------------------------------------------------#
...
@@ -143,6 +185,9 @@ if __name__ == "__main__":
...
@@ -143,6 +185,9 @@ if __name__ == "__main__":
#--------------------------------------------------#
#--------------------------------------------------#
#
#
# $Log: call_ioc_ins,v $
# $Log: call_ioc_ins,v $
# Revision 1.5 2004/07/26 11:39:38 maden
# Add time-out
#
# Revision 1.4 2004/07/26 09:33:25 maden
# Revision 1.4 2004/07/26 09:33:25 maden
# Disable database update ... server is in trouble.
# Disable database update ... server is in trouble.
#
#
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment