projects
/
snf-image-creator
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Support mounting freebsd ufs filesystems
[snf-image-creator]
/
image_creator
/
dialog_main.py
diff --git
a/image_creator/dialog_main.py
b/image_creator/dialog_main.py
index
21fa873
..
7e6b33d
100644
(file)
--- a/
image_creator/dialog_main.py
+++ b/
image_creator/dialog_main.py
@@
-48,15
+48,14
@@
from image_creator.output.cli import SimpleOutput
from image_creator.output.dialog import GaugeOutput
from image_creator.output.composite import CompositeOutput
from image_creator.disk import Disk
from image_creator.output.dialog import GaugeOutput
from image_creator.output.composite import CompositeOutput
from image_creator.disk import Disk
-from image_creator.os_type import os_cls
-from image_creator.dialog_wizard import wizard
+from image_creator.dialog_wizard import start_wizard
from image_creator.dialog_menu import main_menu
from image_creator.dialog_util import SMALL_WIDTH, WIDTH, confirm_exit, \
Reset, update_background_title
from image_creator.dialog_menu import main_menu
from image_creator.dialog_util import SMALL_WIDTH, WIDTH, confirm_exit, \
Reset, update_background_title
-def image_creator(d, media, out, tmp):
-
+def create_image(d, media, out, tmp):
+ """Create an image out of `media'"""
d.setBackgroundTitle('snf-image-creator')
gauge = GaugeOutput(d, "Initialization", "Initializing...")
d.setBackgroundTitle('snf-image-creator')
gauge = GaugeOutput(d, "Initialization", "Initializing...")
@@
-71,19
+70,14
@@
def image_creator(d, media, out, tmp):
signal.signal(signal.SIGTERM, signal_handler)
try:
snapshot = disk.snapshot()
signal.signal(signal.SIGTERM, signal_handler)
try:
snapshot = disk.snapshot()
- dev = disk.get_device(snapshot)
+ image = disk.get_image(snapshot)
+ out.output("Collecting image metadata...")
metadata = {}
metadata = {}
- for (key, value) in dev.meta.items():
+ for (key, value) in image.meta.items():
metadata[str(key)] = str(value)
metadata[str(key)] = str(value)
- dev.mount(readonly=True)
- out.output("Collecting image metadata...")
- cls = os_cls(dev.distro, dev.ostype)
- image_os = cls(dev.root, dev.g, out)
- dev.umount()
-
- for (key, value) in image_os.meta.items():
+ for (key, value) in image.os.meta.items():
metadata[str(key)] = str(value)
out.success("done")
metadata[str(key)] = str(value)
out.success("done")
@@
-97,9
+91,7
@@
def image_creator(d, media, out, tmp):
session = {"dialog": d,
"disk": disk,
session = {"dialog": d,
"disk": disk,
- "snapshot": snapshot,
- "device": dev,
- "image_os": image_os,
+ "image": image,
"metadata": metadata}
msg = "snf-image-creator detected a %s system on the input media. " \
"metadata": metadata}
msg = "snf-image-creator detected a %s system on the input media. " \
@@
-107,8
+99,9
@@
def image_creator(d, media, out, tmp):
"image creation process?\n\nChoose <Wizard> to run the wizard," \
" <Expert> to run the snf-image-creator in expert mode or " \
"press ESC to quit the program." \
"image creation process?\n\nChoose <Wizard> to run the wizard," \
" <Expert> to run the snf-image-creator in expert mode or " \
"press ESC to quit the program." \
- % (dev.ostype if dev.ostype == dev.distro else "%s (%s)" %
- (dev.ostype, dev.distro))
+ % (image.ostype if image.ostype == image.distro or
+ image.distro == "unknown" else "%s (%s)" %
+ (image.ostype, image.distro))
update_background_title(session)
update_background_title(session)
@@
-116,7
+109,7
@@
def image_creator(d, media, out, tmp):
code = d.yesno(msg, width=WIDTH, height=12, yes_label="Wizard",
no_label="Expert")
if code == d.DIALOG_OK:
code = d.yesno(msg, width=WIDTH, height=12, yes_label="Wizard",
no_label="Expert")
if code == d.DIALOG_OK:
- if wizard(session):
+ if start_wizard(session):
break
elif code == d.DIALOG_CANCEL:
main_menu(session)
break
elif code == d.DIALOG_CANCEL:
main_menu(session)
@@
-133,6
+126,10
@@
def image_creator(d, media, out, tmp):
def select_file(d, media):
def select_file(d, media):
+ """Select a media file"""
+ if media == '/':
+ return '/'
+
default = os.getcwd() + os.sep
while 1:
if media is not None:
default = os.getcwd() + os.sep
while 1:
if media is not None:
@@
-222,7
+219,7
@@
def main():
out = CompositeOutput([log])
out.output("Starting %s v%s..." %
(parser.get_prog_name(), version))
out = CompositeOutput([log])
out.output("Starting %s v%s..." %
(parser.get_prog_name(), version))
- ret = image_creator(d, media, out, options.tmp)
+ ret = create_image(d, media, out, options.tmp)
sys.exit(ret)
except Reset:
log.output("Resetting everything...")
sys.exit(ret)
except Reset:
log.output("Resetting everything...")