Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
ulg
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
labs
ulg
Commits
523d16d3
Commit
523d16d3
authored
Oct 26, 2012
by
Tomas Hlavacek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BIRD python pexpect handling fixed.
parent
b76d1898
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
src/ulgbird.py
src/ulgbird.py
+7
-7
No files found.
src/ulgbird.py
View file @
523d16d3
...
...
@@ -567,31 +567,31 @@ class BirdRouterRemote(ulgmodel.RemoteRouter,BirdRouter):
def
runRawCommand
(
self
,
command
,
outfile
):
c
=
'/bin/bash -c
\'
echo "'
+
command
+
'" | '
+
self
.
bin_ssh
+
' -p'
+
str
(
self
.
getPort
())
+
' '
+
str
(
self
.
getUser
())
+
'@'
+
self
.
getHost
()
+
' '
+
self
.
bin_birdc
+
'
\'
'
p
=
pexpect
.
spawn
(
c
)
s
=
pexpect
.
spawn
(
c
)
#
p
.logfile = open('/tmp/ulgbird.log', 'w')
#
s
.logfile = open('/tmp/ulgbird.log', 'w')
# handle ssh
y
=
0
p
=
0
while
True
:
i
=
p
.
expect
([
STRING_EXPECT_SSH_NEWKEY
,
STRING_EXPECT_PASSWORD
,
pexpect
.
EOF
,
pexpect
.
TIMEOUT
])
i
=
s
.
expect
([
STRING_EXPECT_SSH_NEWKEY
,
STRING_EXPECT_PASSWORD
,
pexpect
.
EOF
,
pexpect
.
TIMEOUT
])
if
(
i
==
0
):
if
(
y
>
1
):
raise
Exception
(
"pexpect session failed: Can not save SSH key."
)
p
.
sendline
(
'yes'
)
s
.
sendline
(
'yes'
)
y
+=
1
elif
(
i
==
1
):
if
(
p
>
1
):
raise
Exception
(
"pexpect session failed: Password not accepted."
)
p
.
sendline
(
self
.
password
)
s
.
sendline
(
self
.
password
)
p
+=
1
elif
(
i
==
2
):
# EOF -> process output
break
else
:
raise
Exception
(
"pexpect session failed: Unknown error. last output: "
+
p
.
before
)
raise
Exception
(
"pexpect session failed: Unknown error. last output: "
+
s
.
before
)
def
stripFirstLine
(
string
):
...
...
@@ -601,7 +601,7 @@ class BirdRouterRemote(ulgmodel.RemoteRouter,BirdRouter):
r
=
r
+
l
+
'
\n
'
return
r
out
=
p
.
before
out
=
s
.
before
# ulgmodel.debug("BIRD OUT: "+out)
outfile
.
write
(
stripFirstLine
(
out
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment