Revision cf4f52b6

b/image_creator/dialog_main.py
265 265
        break
266 266

  
267 267
    out = GaugeOutput(d, "Image Upload", "Uploading...")
268
    if 'checksum' not in session:
269
        md5 = MD5(out)
270
        session['checksum'] = md5.compute(session['snapshot'], size)
271 268
    try:
269
        if 'checksum' not in session:
270
            md5 = MD5(out)
271
            session['checksum'] = md5.compute(session['snapshot'], size)
272 272
        kamaki = Kamaki(session['account'], session['token'], out)
273 273
        try:
274 274
            # Upload image file
......
364 364
def kamaki_menu(session):
365 365
    d = session['dialog']
366 366
    default_item = "Account"
367

  
368
    (session['account'], session['token']) = Kamaki.saved_credentials()
367 369
    while 1:
368 370
        account = session["account"] if "account" in session else "<none>"
369 371
        token = session["token"] if "token" in session else "<none>"
......
395 397
                    del session["account"]
396 398
            else:
397 399
                session["account"] = answer.strip()
400
                Kamaki.save_account(session['account'])
398 401
                default_item = "Token"
399 402
        elif choice == "Token":
400 403
            default_item = "Token"
......
408 411
                del session["token"]
409 412
            else:
410 413
                session["token"] = answer.strip()
414
                Kamaki.save_token(session['account'])
411 415
                default_item = "Upload"
412 416
        elif choice == "Upload":
413 417
            if upload_image(session):
......
855 859
                   "image_os": image_os,
856 860
                   "metadata": metadata}
857 861

  
858
        msg = "Would you like to run the snf-image-creator wizard? " \
859
              "Choose <Yes> if you want to run a wizards to assists " \
860
              "you through the image creation process. Choose <No> to run " \
861
              "the program in expert mode."
862
        msg = "snf-image-creator detected a %s system on the input media. " \
863
              "Would you like to run a wizards to assists you through the " \
864
              "image creation process?\n\nChoose <Yes> to run the wizard, " \
865
              "<No> to run the snf-image-creator in expert mode or press " \
866
              "ESC to quit the program." \
867
              % (dev.ostype if dev.ostype == dev.distro else "%s/%s" %
868
                 (dev.distro, dev.ostype))
869

  
870
        while True:
871
            code = d.yesno(msg, width=YESNO_WIDTH, height=12)
872
            if code == d.DIALOG_OK:
873
                if wizard(session):
874
                    break
875
            elif code == d.DIALOG_CANCEL:
876
                main_menu(session)
877
                break
862 878

  
863
        if d.yesno(msg, width=YESNO_WIDTH):
864
            main_menu(session)
865
        else:
866
            wizard(session)
879
            exit_msg = "You have not selected if you want to run " \
880
                       "snf-image-creator in wizard or expert mode."
881
            if confirm_exit(d, exit_msg):
882
                break
867 883

  
868 884
        d.infobox("Thank you for using snf-image-creator. Bye", width=53)
869 885
    finally:
b/image_creator/kamaki_wrapper.py
44 44

  
45 45

  
46 46
class Kamaki(object):
47

  
48
    @staticmethod
49
    def saved_credentials():
50
        config = Config()
51
        account = config.get('storage', 'account')
52
        token = config.get('global', 'token')
53

  
54
        return (account, token)
55

  
56
    @staticmethod
57
    def save_account(account):
58
        config = Config()
59
        config.set('storage', 'account', account)
60
        config.write()
61

  
62
    @staticmethod
63
    def save_token(token):
64
        config = Config()
65
        config.set('global', 'token', token)
66
        config.write()
67

  
47 68
    def __init__(self, account, token, output):
48 69
        self.account = account
49 70
        self.token = token
......
53 74

  
54 75
        pithos_url = config.get('storage', 'url')
55 76
        self.container = CONTAINER
56
        self.pithos_client = PithosClient(pithos_url, token, self.account,
77
        self.pithos_client = PithosClient(pithos_url, self.token, self.account,
57 78
                                          self.container)
58 79

  
59 80
        image_url = config.get('image', 'url')
60
        self.image_client = ImageClient(image_url, token)
61

  
62
        self.uploaded_object = None
81
        self.image_client = ImageClient(image_url, self.token)
63 82

  
64 83
    def upload(self, file_obj, size=None, remote_path=None, hp=None, up=None):
65 84
        """Upload a file to pithos"""

Also available in: Unified diff