yield
return progress_gen
+
class Kamaki:
def __init__(self, account, token):
self.account = account
raise FatalError("Pithos client: %d %s" % (e.status, e.message))
def register(self, name, location, metadata):
- params = {'is_public':'true', 'disk_format':'diskdump'}
+
+ params = {'is_public': 'true', 'disk_format': 'diskdump'}
try:
self.image_client.register(name, location, params, metadata)
except ClientError as e:
output('Dumping md5sum file...', False)
with open('%s.%s' % (options.outfile, 'md5sum'), 'w') as f:
- f.write('%s %s'% (checksum, os.path.basename(options.outfile)))
+ f.write('%s %s' % (
+ checksum, os.path.basename(options.outfile)))
success('done')
# Destroy the device. We only need the snapshot from now on
output()
if options.register:
- output('Registing image to ~okeanos...')
+ output('Registing image to ~okeanos...', False)
kamaki.register(options.register, uploaded_obj, metadata)
- output('done')
+ success('done')
output()
finally:
import sys
import pbs
import hashlib
-from clint.textui import colored
+from colors import red, green, yellow
from progress.bar import Bar
def error(msg, new_line=True):
nl = "\n" if new_line else ''
- sys.stderr.write(colored.red('Error: %s' % msg) + nl)
+ sys.stderr.write(red('Error: %s' % msg) + nl)
def warn(msg, new_line=True):
if not silent:
nl = "\n" if new_line else ''
- sys.stderr.write(colored.yellow("Warning: %s" % msg) + nl)
+ sys.stderr.write(yellow("Warning: %s" % msg) + nl)
def success(msg, new_line=True):
if not silent:
nl = "\n" if new_line else ''
- sys.stdout.write(colored.green(msg) + nl)
+ sys.stdout.write(green(msg) + nl)
if not nl:
sys.stdout.flush()
def progress(message='', bar_type="default"):
MESSAGE_LENGTH = 30
-
- suffix={'default':'%(index)d/%(max)d',
- 'percent':'%(percent)d%%',
- 'b':'%(index)d/%(max)d B',
- 'kb':'%(index)d/%(max)d KB',
- 'mb':'%(index)d/%(max)d MB'}
- return Bar(message=message.ljust(MESSAGE_LENGTH), fill='#', \
- suffix=suffix[bar_type])
+ suffix = {
+ 'default': '%(index)d/%(max)d',
+ 'percent': '%(percent)d%%',
+ 'b': '%(index)d/%(max)d B',
+ 'kb': '%(index)d/%(max)d KB',
+ 'mb': '%(index)d/%(max)d MB'
+ }
+
+ bar = Bar()
+ bar.message = message.ljust(MESSAGE_LENGTH)
+ bar.fill = '#'
+ bar.suffix = suffix[bar_type]
+ bar.bar_prefix = ' ['
+ bar.bar_suffix = '] '
+
+ return bar
+
def md5(filename, size):
md5.update(data)
left -= length
progressbar.goto((size - left) // (2 ** 20))
-
+
checksum = md5.hexdigest()
output("\rCalculating md5sum...\033[K", False)
success(checksum)
license='BSD',
packages=['image_creator', 'image_creator.os_type'],
include_package_data=True,
- install_requires=['pbs', 'clint', 'progress','pysendfile'],
+ install_requires=['pbs', 'ansicolors', 'progress', 'pysendfile'],
entry_points={
'console_scripts': ['snf-image-creator = image_creator.main:main']
}