Skip to content

Commit

Permalink
Pet pep8.
Browse files Browse the repository at this point in the history
  • Loading branch information
novel committed Jul 15, 2010
1 parent aff9339 commit 1273a7e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion lc-node-add
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import sys
from lctools.lc import get_lc
from lctools.printer import Printer


def usage(prog):
sys.stdout.write("%s -i <image_id> -s <size_id> -n <name>\n\n" % prog)

Expand Down Expand Up @@ -36,7 +37,8 @@ if __name__ == "__main__":
sys.exit(1)

nodeimage = filter(lambda img: str(img.id) == image, conn.list_images())[0]
nodesize = filter(lambda sz: str(sz.id).lower() == size.lower(), conn.list_sizes())[0]
nodesize = filter(lambda sz: str(sz.id).lower() == size.lower(),
conn.list_sizes())[0]

node = conn.create_node(name=name, image=nodeimage, size=nodesize)
print node
8 changes: 5 additions & 3 deletions lc-node-do
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import sys
from lctools.lc import get_lc
from lctools.printer import Printer


def usage(progname):
sys.stdout.write("%s -i <node_id> [reboot|destroy]\n\n" % progname)

Expand All @@ -24,11 +25,11 @@ if __name__ == "__main__":
profile = a
if o == "-i":
node_id = a

if 0 == len(args):
usage(sys.argv[0])
sys.exit(1)

action = args[0]

if node_id is None:
Expand All @@ -38,7 +39,8 @@ if __name__ == "__main__":
conn = get_lc(profile)

try:
node = filter(lambda node: str(node.id) == node_id, conn.list_nodes())[0]
node = filter(lambda node: str(node.id) == node_id,
conn.list_nodes())[0]
except IndexError:
sys.stderr.write("No node with id %s found." % node_id)
sys.exit(1)
Expand Down
2 changes: 2 additions & 0 deletions lctools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

LC_CONFIG = "~/.lcrc"


class MyConfig(ConfigParser.ConfigParser):
profile = None

Expand All @@ -13,6 +14,7 @@ def __init__(self, profile):
def get(self, option):
return ConfigParser.ConfigParser.get(self, self.profile, option)


def get_config(profile):
conf = MyConfig(profile)
conf.read(os.path.expanduser(LC_CONFIG))
Expand Down
1 change: 1 addition & 0 deletions lctools/lc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from config import get_config


def get_lc(profile):
conf = get_config(profile)

Expand Down
1 change: 1 addition & 0 deletions lctools/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
NodeState.PENDING: "Pending",
NodeState.UNKNOWN: "Unknown"}


class Printer(object):
_formats = {"nodeimage": "image %(name)s (id = %(id)s)",
"nodesize": "size %(name)s (id=%(id)s, ram=%(ram)s, disk=%(disk)s bandwidth=%(bandwidth)s)"}
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@
"lc-node-add",
"lc-node-do",
"lc-node-list",
"lc-sizes-list"]
)
"lc-sizes-list"])

0 comments on commit 1273a7e

Please sign in to comment.