Commit a1f378f7 authored by Marco Mariani's avatar Marco Mariani

some whitespace/indent changes to please pep8

parent 314fd21e
......@@ -80,6 +80,7 @@ class ClientConfig(object):
if self.cert_file:
self.cert_file = os.path.expanduser(self.cert_file)
def init(conf):
"""Initialize Slap instance, connect to server and create
aliases to common software releases"""
......@@ -122,13 +123,13 @@ def do_request(conf, local):
conf.software_url = local[conf.software_url]
try:
partition = local['slap'].registerOpenOrder().request(
software_release = conf.software_url,
partition_reference = conf.reference,
partition_parameter_kw = conf.parameters,
software_type = conf.type,
filter_kw = conf.node,
state = conf.state,
shared = conf.slave
software_release=conf.software_url,
partition_reference=conf.reference,
partition_parameter_kw=conf.parameters,
software_type=conf.type,
filter_kw=conf.node,
state=conf.state,
shared=conf.slave
)
print "Instance requested.\nState is : %s." % partition.getState()
print "Connection parameters of instance are:"
......@@ -185,6 +186,7 @@ def do_console(local):
readline.parse_and_bind("tab: complete")
historyPath = os.path.expanduser("~/.slapconsolehistory")
def save_history(historyPath=historyPath):
readline.write_history_file(historyPath)
if os.path.exists(historyPath):
......
......@@ -307,7 +307,6 @@ class Computer(object):
with open(path_to_xml, 'wb') as fout:
fout.write(new_pretty_xml)
def backup_xml(self, path_to_archive, path_to_xml):
"""
Stores a copy of the current xml file to an historical archive.
......@@ -318,7 +317,6 @@ class Computer(object):
with zipfile.ZipFile(path_to_archive, 'a') as archive:
archive.writestr(saved_filename, xml_content, zipfile.ZIP_DEFLATED)
@classmethod
def load(cls, path_to_xml, reference, ipv6_interface):
"""
......@@ -336,11 +334,11 @@ class Computer(object):
# Reconstructing the computer object from the xml
computer = Computer(
reference = reference,
addr = dumped_dict['address'],
netmask = dumped_dict['netmask'],
ipv6_interface = ipv6_interface,
software_user = dumped_dict.get('software_user', 'slapsoft'),
reference=reference,
addr=dumped_dict['address'],
netmask=dumped_dict['netmask'],
ipv6_interface=ipv6_interface,
software_user=dumped_dict.get('software_user', 'slapsoft'),
)
for partition_dict in dumped_dict['partition_list']:
......@@ -358,11 +356,11 @@ class Computer(object):
address_list = partition_dict['address_list']
partition = Partition(
reference = partition_dict['reference'],
path = partition_dict['path'],
user = user,
address_list = address_list,
tap = tap,
reference=partition_dict['reference'],
path=partition_dict['path'],
user=user,
address_list=address_list,
tap=tap,
)
computer.partition_list.append(partition)
......@@ -730,7 +728,7 @@ class Interface(object):
if isGlobalScopeAddress(q['addr'].split('%')[0])
]
except KeyError:
raise ValueError("%s must have at least one IPv6 address assigned" % \
raise ValueError("%s must have at least one IPv6 address assigned" %
interface_name)
if sys.platform == 'cygwin':
for q in address_list:
......@@ -838,8 +836,8 @@ class Interface(object):
while try_num > 0:
addr = random.choice([q for q in netaddr.glob_to_iprange(
netaddr.cidr_to_glob(self.ipv4_local_network))]).format()
if dict(addr=addr, netmask=netmask) not in \
self.getIPv4LocalAddressList():
if (dict(addr=addr, netmask=netmask) not in
self.getIPv4LocalAddressList()):
# Checking the validity of the IPv6 address
if self._addSystemAddress(addr, netmask, False):
return dict(addr=addr, netmask=netmask)
......@@ -926,8 +924,8 @@ class Interface(object):
addr = ':'.join(address_dict['addr'].split(':')[:-1] + ['%x' % (
random.randint(1, 65000), )])
socket.inet_pton(socket.AF_INET6, addr)
if dict(addr=addr, netmask=netmask) not in \
self.getGlobalScopeAddressList():
if (dict(addr=addr, netmask=netmask) not in
self.getGlobalScopeAddressList()):
# Checking the validity of the IPv6 address
if self._addSystemAddress(addr, netmask):
return dict(addr=addr, netmask=netmask)
......@@ -947,8 +945,8 @@ def parse_computer_definition(conf, definition_path):
netmask = None
if computer_definition.has_option('computer', 'address'):
address, netmask = computer_definition.get('computer', 'address').split('/')
if conf.alter_network and conf.interface_name is not None \
and conf.ipv4_local_network is not None:
if (conf.alter_network and conf.interface_name is not None
and conf.ipv4_local_network is not None):
interface = Interface(logger=conf.logger,
name=conf.interface_name,
ipv4_local_network=conf.ipv4_local_network,
......
# -*- coding: utf-8 -*-
import os, errno
import errno
import os
def mkdir_p(path, mode=0o777):
"""\
......@@ -17,6 +19,7 @@ def mkdir_p(path, mode=0o777):
else:
raise
def chownDirectory(path, uid, gid):
os.chown(path, uid, gid)
for root, dirs, files in os.walk(path):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment