Skip to content
This repository has been archived by the owner on Oct 10, 2020. It is now read-only.

Commit

Permalink
Merge pull request #88 from willmtemple/code-smell
Browse files Browse the repository at this point in the history
PEP8 (Python style guide) Compliance
  • Loading branch information
rhatdan committed Jul 29, 2015
2 parents edb0bea + 179a121 commit f1bde87
Show file tree
Hide file tree
Showing 9 changed files with 426 additions and 263 deletions.
16 changes: 11 additions & 5 deletions Atomic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import sys, os
import sys
import os
from .pulp import PulpServer
from .config import PulpConfig
from .atomic import Atomic


def writeOut(output, lf="\n"):
sys.stdout.flush()
sys.stdout.write(str(output) + lf)

def push_image_to_pulp(image, server_url, username, password, verify_ssl, docker_client):

def push_image_to_pulp(image, server_url, username, password, verify_ssl,
docker_client):
if not image:
raise ValueError("Image required")
parts = image.split("/")
Expand All @@ -16,7 +20,7 @@ def push_image_to_pulp(image, server_url, username, password, verify_ssl, docker
server_url = parts[0]
image = ("/").join(parts[1:])

repo = image.replace("/","-")
repo = image.replace("/", "-")
if not server_url:
raise ValueError("Server url required")

Expand All @@ -25,7 +29,8 @@ def push_image_to_pulp(image, server_url, username, password, verify_ssl, docker

try:
pulp = PulpServer(server_url=server_url, username=username,
password=password, verify_ssl=verify_ssl, docker_client=docker_client)
password=password, verify_ssl=verify_ssl,
docker_client=docker_client)
except Exception as e:
raise IOError('Failed to initialize Pulp: {0}'.format(e))

Expand All @@ -36,7 +41,8 @@ def push_image_to_pulp(image, server_url, username, password, verify_ssl, docker
raise IOError('Failed to create Pulp repository: {0}'.format(e))

try:
writeOut('Uploading image "{0}" to pulp server "{1}"'.format(image, server_url))
writeOut('Uploading image "{0}" to pulp server "{1}"'
''.format(image, server_url))
pulp.upload_docker_image(image, repo)
writeOut("")
except Exception as e:
Expand Down
Loading

0 comments on commit f1bde87

Please sign in to comment.