+
+ d = session['dialog']
+ clouds = Kamaki.get_clouds()
+ if not len(clouds):
+ if not add_cloud(session):
+ return False
+ else:
+ while 1:
+ choices = []
+ for (name, cloud) in clouds.items():
+ descr = cloud['description'] if 'description' in cloud else ''
+ choices.append((name, descr))
+
+ (code, choice) = d.menu(
+ "In this menu you can select existing cloud account to use "
+ " or add new ones. Press <Select> to select an existing "
+ "account or <Add> to add a new one.", height=18,
+ width=PAGE_WIDTH, choices=choices, menu_height=10,
+ ok_label="Select", extra_button=1, extra_label="Add",
+ title="Clouds")
+
+ if code in (d.DIALOG_CANCEL, d.DIALOG_ESC):
+ return False
+ elif code == d.DIALOG_OK: # Select button
+ account = Kamaki.get_account(choice)
+ if not account:
+ if not d.yesno("Then cloud you have selected is not "
+ "valid! Would you like to edit it?",
+ width=PAGE_WIDTH, defaultno=0):
+ edit_cloud(session, choice)
+ continue
+ break
+ elif code == d.DIALOG_EXTRA: # Add button
+ add_cloud(session)