Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gabriel Monnerat
slapos.core
Commits
bd778c5f
Commit
bd778c5f
authored
May 28, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use dict literals, except..as syntax
parent
504ba6e6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
26 deletions
+26
-26
slapos/slap/slap.py
slapos/slap/slap.py
+26
-26
No files found.
slapos/slap/slap.py
View file @
bd778c5f
...
@@ -448,13 +448,13 @@ class ComputerPartition(SlapRequester):
...
@@ -448,13 +448,13 @@ class ComputerPartition(SlapRequester):
'message'
:
message
})
'message'
:
message
})
def
rename
(
self
,
new_name
,
slave_reference
=
None
):
def
rename
(
self
,
new_name
,
slave_reference
=
None
):
post_dict
=
dict
(
post_dict
=
{
computer_id
=
self
.
_computer_id
,
'computer_id'
:
self
.
_computer_id
,
computer_partition_id
=
self
.
getId
(),
'computer_partition_id'
:
self
.
getId
(),
new_name
=
new_name
,
'new_name'
:
new_name
,
)
}
if
slave_reference
is
not
None
:
if
slave_reference
:
post_dict
.
update
(
slave_reference
=
slave_reference
)
post_dict
[
'slave_reference'
]
=
slave_reference
self
.
_connection_helper
.
POST
(
'/softwareInstanceRename'
,
post_dict
)
self
.
_connection_helper
.
POST
(
'/softwareInstanceRename'
,
post_dict
)
def
getId
(
self
):
def
getId
(
self
):
...
@@ -569,14 +569,14 @@ class ConnectionHelper:
...
@@ -569,14 +569,14 @@ class ConnectionHelper:
return
xml_marshaller
.
loads
(
xml
)
return
xml_marshaller
.
loads
(
xml
)
def
connect
(
self
):
def
connect
(
self
):
connection_dict
=
dict
(
connection_dict
=
{
host
=
self
.
host
)
'host'
:
self
.
host
}
if
self
.
key_file
and
self
.
cert_file
:
if
self
.
key_file
and
self
.
cert_file
:
connection_dict
.
update
(
connection_dict
[
'key_file'
]
=
self
.
key_file
key_file
=
self
.
key_file
,
connection_dict
[
'cert_file'
]
=
self
.
cert_file
cert_file
=
self
.
cert_file
)
if
self
.
master_ca_file
:
if
self
.
master_ca_file
is
not
None
:
connection_dict
[
'ca_file'
]
=
self
.
master_ca_file
connection_dict
.
update
(
ca_file
=
self
.
master_ca_file
)
self
.
connection
=
self
.
connection_wrapper
(
**
connection_dict
)
self
.
connection
=
self
.
connection_wrapper
(
**
connection_dict
)
def
GET
(
self
,
path
):
def
GET
(
self
,
path
):
...
@@ -588,14 +588,14 @@ class ConnectionHelper:
...
@@ -588,14 +588,14 @@ class ConnectionHelper:
self
.
connection
.
request
(
'GET'
,
self
.
path
+
path
)
self
.
connection
.
request
(
'GET'
,
self
.
path
+
path
)
response
=
self
.
connection
.
getresponse
()
response
=
self
.
connection
.
getresponse
()
# If ssl error : may come from bad configuration
# If ssl error : may come from bad configuration
except
ssl
.
SSLError
,
e
:
except
ssl
.
SSLError
as
exc
:
if
e
.
message
==
"The read operation timed out"
:
if
e
xc
.
message
==
'The read operation timed out'
:
raise
socket
.
error
(
str
(
e
)
+
self
.
error_message_timeout
)
raise
socket
.
error
(
str
(
e
xc
)
+
self
.
error_message_timeout
)
raise
ssl
.
SSLError
(
str
(
e
)
+
self
.
ssl_error_message_connect_fail
)
raise
ssl
.
SSLError
(
str
(
e
xc
)
+
self
.
ssl_error_message_connect_fail
)
except
socket
.
error
,
e
:
except
socket
.
error
as
exc
:
if
e
.
message
==
"timed out"
:
if
e
xc
.
message
==
'timed out'
:
raise
socket
.
error
(
str
(
e
)
+
self
.
error_message_timeout
)
raise
socket
.
error
(
str
(
e
xc
)
+
self
.
error_message_timeout
)
raise
socket
.
error
(
self
.
error_message_connect_fail
+
str
(
e
))
raise
socket
.
error
(
self
.
error_message_connect_fail
+
str
(
e
xc
))
# check self.response.status and raise exception early
# check self.response.status and raise exception early
if
response
.
status
==
httplib
.
REQUEST_TIMEOUT
:
if
response
.
status
==
httplib
.
REQUEST_TIMEOUT
:
...
@@ -626,10 +626,10 @@ class ConnectionHelper:
...
@@ -626,10 +626,10 @@ class ConnectionHelper:
self
.
connection
.
request
(
"POST"
,
self
.
path
+
path
,
self
.
connection
.
request
(
"POST"
,
self
.
path
+
path
,
urllib
.
urlencode
(
parameter_dict
),
header_dict
)
urllib
.
urlencode
(
parameter_dict
),
header_dict
)
# If ssl error : must come from bad configuration
# If ssl error : must come from bad configuration
except
ssl
.
SSLError
,
e
:
except
ssl
.
SSLError
as
exc
:
raise
ssl
.
SSLError
(
self
.
ssl_error_message_connect_fail
+
str
(
e
))
raise
ssl
.
SSLError
(
self
.
ssl_error_message_connect_fail
+
str
(
e
xc
))
except
socket
.
error
,
e
:
except
socket
.
error
as
exc
:
raise
socket
.
error
(
self
.
error_message_connect_fail
+
str
(
e
))
raise
socket
.
error
(
self
.
error_message_connect_fail
+
str
(
e
xc
))
response
=
self
.
connection
.
getresponse
()
response
=
self
.
connection
.
getresponse
()
# check self.response.status and raise exception early
# check self.response.status and raise exception early
...
...
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