Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snf-image-creator
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
itminedu
snf-image-creator
Commits
3c33e68a
Commit
3c33e68a
authored
12 years ago
by
Nikos Skalkotos
Browse files
Options
Downloads
Patches
Plain Diff
Add all wizard dialog boxes.
The system does not perform anything yet when in wizard mode.
parent
24684bbb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
image_creator/dialog_main.py
+2
-0
2 additions, 0 deletions
image_creator/dialog_main.py
image_creator/dialog_wizard.py
+61
-51
61 additions, 51 deletions
image_creator/dialog_wizard.py
with
63 additions
and
51 deletions
image_creator/dialog_main.py
+
2
−
0
View file @
3c33e68a
...
...
@@ -871,6 +871,8 @@ def image_creator(d):
%
(
dev
.
ostype
if
dev
.
ostype
==
dev
.
distro
else
"
%s/%s
"
%
(
dev
.
distro
,
dev
.
ostype
))
update_background_title
(
session
)
while
True
:
code
=
d
.
yesno
(
msg
,
width
=
YESNO_WIDTH
,
height
=
12
)
if
code
==
d
.
DIALOG_OK
:
...
...
This diff is collapsed.
Click to expand it.
image_creator/dialog_wizard.py
+
61
−
51
View file @
3c33e68a
...
...
@@ -35,79 +35,89 @@
import
dialog
class
WizardPage
:
NEXT
=
1
PREV
=
-
1
from
image_creator.kamaki_wrapper
import
Kamaki
def
__init__
(
self
,
session
,
title
):
self
.
session
=
session
self
.
title
=
title
PAGE_WIDTH
=
70
def
run
(
self
):
raise
NotImplementedError
class
Wizard
:
def
__init__
(
self
,
session
):
self
.
session
=
session
self
.
pages
=
[]
self
.
session
[
'
wizard
'
]
=
{}
def
add_page
(
self
,
page
):
self
.
pages
.
append
(
page
)
class
ImageName
(
WizardPage
):
def
run
(
self
):
d
=
self
.
session
[
'
dialog
'
]
w
=
self
.
session
[
'
wizard
'
]
init
=
w
[
'
ImageName
'
]
if
'
ImageName
'
in
w
else
""
while
1
:
(
code
,
answer
)
=
d
.
inputbox
(
"
Please provide a name for the image:
"
,
init
=
init
,
width
=
INPUTBOX_WIDTH
,
ok_label
=
"
Next
"
,
cancel
=
"
Back
"
,
title
=
self
.
title
)
idx
=
0
while
True
:
idx
+=
self
.
pages
[
idx
].
run
(
self
.
session
,
idx
,
len
(
self
.
pages
))
if
code
in
(
d
.
DIALOG_CANCEL
,
d
.
DIALOG_ESC
):
re
turn
self
.
PREV
if
idx
>=
len
(
self
.
pages
):
b
re
ak
name
=
answer
.
strip
()
if
len
(
name
)
==
0
:
d
.
msgbox
(
"
Image name cannot be empty
"
,
width
=
MSGBOX_WIDTH
)
continue
w
[
'
ImageName
'
]
=
name
break
if
idx
<
0
:
return
False
return
True
return
self
.
NEXT
class
WizardPage
:
NEXT
=
1
PREV
=
-
1
class
ImageDescription
(
WizardPage
):
def
run
(
self
):
d
=
self
.
session
[
'
dialog
'
]
w
=
self
.
session
[
'
wizard
'
]
def
__init__
(
self
,
name
,
message
,
**
kargs
):
self
.
name
=
name
self
.
message
=
message
self
.
title
=
kargs
[
'
title
'
]
if
'
title
'
in
kargs
else
''
self
.
init_value
=
kargs
[
'
init
'
]
if
'
init
'
in
kargs
else
''
self
.
allow_empty
=
kargs
[
'
empty
'
]
if
'
empty
'
in
kargs
else
False
init
=
w
[
'
ImageDescription
'
]
if
'
ImageDescription
'
in
w
else
""
def
run
(
self
,
session
,
index
,
total
):
d
=
session
[
'
dialog
'
]
w
=
session
[
'
wizard
'
]
while
1
:
(
code
,
answer
)
=
d
.
inputbox
(
"
Please provide a description for the image:
"
,
init
=
init
,
width
=
INPUTBOX_WIDTH
,
ok_label
=
"
Next
"
,
cancel
=
"
Back
"
,
title
=
self
.
title
)
init
=
w
[
self
.
name
]
if
self
.
name
in
w
else
self
.
init_value
while
True
:
(
code
,
answer
)
=
d
.
inputbox
(
self
.
message
,
init
=
init
,
width
=
PAGE_WIDTH
,
ok_label
=
"
Next
"
,
cancel
=
"
Back
"
,
title
=
"
(%d/%d) %s
"
%
(
index
+
1
,
total
,
self
.
title
))
if
code
in
(
d
.
DIALOG_CANCEL
,
d
.
DIALOG_ESC
):
return
self
.
PREV
name
=
answer
.
strip
()
if
len
(
filename
)
==
0
:
# Description is allowed to be empty
del
w
[
'
ImageDescription
'
]
else
:
w
[
'
ImageDescription
'
]
=
name
value
=
answer
.
strip
()
if
len
(
value
)
==
0
and
self
.
allow_empty
is
False
:
d
.
msgbox
(
"
The value cannot be empty!
"
,
width
=
PAGE_WIDTH
)
continue
w
[
self
.
name
]
=
value
break
return
self
.
NEXT
def
wizard
(
session
):
session
[
'
wizard
'
]
=
{}
steps
=
[]
steps
.
append
(
ImageName
(
session
,
"
(1/5) Image Name
"
))
steps
.
append
(
ImageDescription
(
session
,
"
(2/5) Image Description
"
))
return
True
name
=
WizardPage
(
"
ImageName
"
,
"
Please provide a name for the image:
"
,
title
=
"
Image Name
"
,
init
=
session
[
'
device
'
].
distro
)
descr
=
WizardPage
(
"
ImageDescription
"
,
"
Please provide a description for the image:
"
,
title
=
"
Image Description
"
,
empty
=
True
,
init
=
session
[
'
metadata
'
][
'
DESCRIPTION
'
]
if
'
DESCRIPTION
'
in
session
[
'
metadata
'
]
else
''
)
account
=
WizardPage
(
"
account
"
,
"
Please provide your ~okeanos account e-mail:
"
,
title
=
"
~okeanos account information
"
,
init
=
Kamaki
.
get_account
())
token
=
WizardPage
(
"
token
"
,
"
Please provide your ~okeanos account token:
"
,
title
=
"
~okeanos account token
"
,
init
=
Kamaki
.
get_token
())
w
=
Wizard
(
session
)
w
.
add_page
(
name
)
w
.
add_page
(
descr
)
w
.
add_page
(
account
)
w
.
add_page
(
token
)
return
w
.
run
()
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment