Commit 78aac79a authored by Constantinos Venetsanopoulos's avatar Constantinos Venetsanopoulos
Browse files

Merge PR #8 (feature-windows-improvements) from skalkoto/snf-image-creator

Changes include:

 * Break windows.py into multiple modules.
 * Rewrite sysprep parameters mechanism and add a menu entry for this
   in snf-image-creator expert mode.
 * Detect if the media is already sysprepped before performing further
   customizatog.
 * Don't ask for windows password before customization (reset it if needed)
 * Detect if the virtio drivers are installed in the media.
   If not refuse to perform the customization.
parents 44d97080 21aa5f16
This diff is collapsed.
......@@ -22,35 +22,18 @@ for more information.
Copyright and license
=====================
Copyright 2012-2014 GRNET S.A. All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:
1. Redistributions of source code must retain the above
copyright notice, this list of conditions and the following
disclaimer.
2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials
provided with the distribution.
THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and
documentation are those of the authors and should not be
interpreted as representing official policies, either expressed
or implied, of GRNET S.A.
Copyright (C) 2011-2014 GRNET S.A.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
#
# Copyright 2012 GRNET S.A. All rights reserved.
# Copyright (C) 2011-2014 GRNET S.A.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Package for creating images to be used with Synnefo open source cloud
software.
......
# -*- coding: utf-8 -*-
#
# Copyright 2012 GRNET S.A. All rights reserved.
# Copyright (C) 2011-2014 GRNET S.A.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""This module hosts the code that performs the host bundling operation. By
using the create_image method of the BundleVolume class the user can create an
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2012 GRNET S.A. All rights reserved.
# Copyright (C) 2011-2014 GRNET S.A.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""This module is the entrance point for the dialog-based version of the
snf-image-creator program. The main function will create a dialog where the
......@@ -42,7 +24,6 @@ user is asked if he wants to use the program in expert or wizard mode.
import dialog
import sys
import os
import stat
import textwrap
import signal
import optparse
......@@ -59,8 +40,8 @@ from image_creator.output.composite import CompositeOutput
from image_creator.disk import Disk
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_util import WIDTH, confirm_exit, Reset, \
update_background_title, select_file
PROGNAME = os.path.basename(sys.argv[0])
......@@ -155,38 +136,6 @@ def create_image(d, media, out, tmp):
return 0
def select_file(d, media):
"""Select a media file"""
if media == '/':
return '/'
default = os.getcwd() + os.sep
while 1:
if media is not None:
if not os.path.exists(media):
d.msgbox("The file `%s' you choose does not exist." % media,
width=SMALL_WIDTH)
else:
mode = os.stat(media).st_mode
if not stat.S_ISDIR(mode):
break
default = media
(code, media) = d.fselect(default, 10, 60, extra_button=1,
title="Please select an input media.",
extra_label="Bundle Host")
if code in (d.DIALOG_CANCEL, d.DIALOG_ESC):
if confirm_exit(d, "You canceled the media selection dialog box."):
sys.exit(0)
else:
media = None
continue
elif code == d.DIALOG_EXTRA:
return '/'
return media
def _dialog_form(self, text, height=20, width=60, form_height=15, fields=[],
**kwargs):
"""Display a form box.
......@@ -247,7 +196,16 @@ def dialog_main(media, logfile, tmpdir):
d.setBackgroundTitle('snf-image-creator')
try:
media = select_file(d, media)
while True:
media = select_file(d, init=media, ftype="br", bundle_host=True,
title="Please select an input media.")
if media is None:
if confirm_exit(
d, "You canceled the media selection dialog box."):
return 0
continue
break
log = SimpleOutput(False, logfile) if logfile is not None else Output()
while 1:
try:
......
# -*- coding: utf-8 -*-
#
# Copyright 2012 GRNET S.A. All rights reserved.
# Copyright (C) 2011-2014 GRNET S.A.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""This module implements the "expert" mode of the dialog-based version of
snf-image-creator.
......@@ -50,7 +32,7 @@ from image_creator.kamaki_wrapper import Kamaki, ClientError
from image_creator.help import get_help_file
from image_creator.dialog_util import SMALL_WIDTH, WIDTH, \
update_background_title, confirm_reset, confirm_exit, Reset, \
extract_image, add_cloud, edit_cloud
extract_image, add_cloud, edit_cloud, select_file
CONFIGURATION_TASKS = [
("Partition table manipulation", ["FixPartitionTable"],
......@@ -578,7 +560,7 @@ def modify_properties(session):
"property?" % choice, width=WIDTH):
del session['metadata'][choice]
d.msgbox("Image property: `%s' was deleted." % choice,
width=SMALL_WIDTH)
width=SMALL_WIDTH)
# ADD button
elif code == d.DIALOG_EXTRA:
add_property(session)
......@@ -658,71 +640,80 @@ def exclude_tasks(session):
return True
def sysprep_params(session):
"""Collect the needed sysprep parameters"""
def update_sysprep_param(session, name):
"""Modify the value of a sysprep parameter"""
d = session['dialog']
image = session['image']
available = image.os.sysprep_params
needed = image.os.needed_sysprep_params
param = image.os.sysprep_params[name]
if len(needed) == 0:
return True
while 1:
if param.type in ("file", "dir"):
def print_form(names, extra_button=False):
"""print the dialog form providing sysprep_params"""
fields = []
for name in names:
param = needed[name]
default = str(available[name]) if name in available else ""
fields.append(("%s: " % param.description, default,
SYSPREP_PARAM_MAXLEN))
kwargs = {}
if extra_button:
kwargs['extra_button'] = 1
kwargs['extra_label'] = "Advanced"
txt = "Please provide the following system preparation parameters:"
return d.form(txt, height=13, width=WIDTH, form_height=len(fields),
fields=fields, **kwargs)
def check_params(names, values):
"""check if the provided sysprep parameters have legal values"""
for i in range(len(names)):
param = needed[names[i]]
try:
normalized = param.type(values[i])
if param.validate(normalized):
image.os.sysprep_params[names[i]] = normalized
continue
except ValueError:
pass
title = "Please select a %s to use for the `%s' parameter" % \
(name, 'file' if param.type == 'file' else 'directory')
ftype = "br" if param.type == 'file' else 'd'
d.msgbox("Invalid value for parameter: `%s'" % names[i],
width=SMALL_WIDTH)
return False
return True
value = select_file(d, ftype=ftype, title=title)
if value is None:
return False
else:
(code, answer) = d.inputbox(
"Please provide a new value for configuration parameter: `%s'"
% name, width=WIDTH, init=str(param.value))
simple_names = [k for k, v in needed.items() if v.default is None]
advanced_names = [k for k, v in needed.items() if v.default is not None]
if code in (d.DIALOG_CANCEL, d.DIALOG_ESC):
return False
while 1:
code, output = print_form(simple_names, extra_button=True)
value = answer.strip()
if code in (d.DIALOG_CANCEL, d.DIALOG_ESC):
return False
if code == d.DIALOG_EXTRA:
while 1:
code, output = print_form(advanced_names)
if code in (d.DIALOG_CANCEL, d.DIALOG_ESC):
break
if check_params(advanced_names, output):
break
if param.set_value(value) is False:
d.msgbox("Unable to update the value. Reason: %s" % param.error,
width=WIDTH)
param.error = None
continue
break
if check_params(simple_names, output):
break
def sysprep_params(session):
"""Collect the needed sysprep parameters"""
d = session['dialog']
image = session['image']
default = None
while 1:
choices = []
for name, param in image.os.sysprep_params.items():
value = str(param.value)
if len(value) == 0:
value = "<empty>"
choices.append((name, value))
if len(choices) == 0:
d.msgbox("No customization parameters available", width=WIDTH)
return True
if default is None:
default = choices[0][0]
(code, choice) = d.menu(
"In this menu you can see and update the value for parameters "
"used in the system preparation tasks. Press <Details> to see "
"more info about a specific configuration parameters and <Update> "
"to update its value. Press <Back> when done.", height=18,
width=WIDTH, choices=choices, menu_height=10, ok_label="Details",
extra_button=1, extra_label="Update", cancel="Back",
default_item=default, title="System Preparation Parameters")
default = choice
if code in (d.DIALOG_CANCEL, d.DIALOG_ESC):
return True
# Details button
elif code == d.DIALOG_OK:
d.msgbox(image.os.sysprep_params[choice].description, width=WIDTH)
else: # Update button
update_sysprep_param(session, choice)
return True
......@@ -791,9 +782,6 @@ def sysprep(session):
title="System Preparation", width=SMALL_WIDTH)
continue
if not sysprep_params(session):
continue
infobox = InfoBoxOutput(d, "Image Configuration")
try:
image.out.add(infobox)
......@@ -860,16 +848,18 @@ def customization_menu(session):
"""Show image customization menu"""
d = session['dialog']
choices = [("Sysprep", "Run various image preparation tasks"),
choices = [("Parameters", "View & Modify customization parameters"),
("Sysprep", "Run various image preparation tasks"),
("Shrink", "Shrink image"),
("Modify", "Modify image properties"),
("Properties", "View & Modify image properties"),
("Exclude", "Exclude various deployment tasks from running")]
default_item = 0
actions = {"Sysprep": sysprep,
actions = {"Parameters": sysprep_params,
"Sysprep": sysprep,
"Shrink": shrink,
"Modify": modify_properties,
"Properties": modify_properties,
"Exclude": exclude_tasks}
while 1:
(code, choice) = d.menu(
......
# -*- coding: utf-8 -*-
#
# Copyright 2012 GRNET S.A. All rights reserved.
# Copyright (C) 2011-2014 GRNET S.A.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Module providing useful functions for the dialog-based version of
snf-image-creator.
"""
import os
import stat
import re
import json
from image_creator.output.dialog import GaugeOutput
......@@ -48,6 +31,74 @@ SMALL_WIDTH = 60
WIDTH = 70
def select_file(d, **kwargs):
"""Select a file or directory.
The following optional arguments can be applied:
* init: Initial file path. If this path is valid this will be returned
* ftype: Allowed file types. If the value of this argument is "br" only
block devices and regular files are valid. For a list of available
file types, see here:
http://libguestfs.org/guestfs.3.html#guestfs_readdir
* title: The dialog box title. The default one is: "Please select a file"
* bundle_host: This can be True or False. If this is True, an extra
"Bundle Host" button will be present if the file selection dialog.
"""
type_check = {'b': stat.S_ISBLK, # Block special
'c': stat.S_ISCHR, # Char special
'd': stat.S_ISDIR, # Directory
'f': stat.S_ISFIFO, # FIFO (named pipe)
'l': stat.S_ISLNK, # Symbolic link
'r': stat.S_ISREG, # Regular file
's': stat.S_ISSOCK} # Socket
fname = None if "init" not in kwargs else kwargs['init']
ftype = set(t for t in kwargs['ftype']) if 'ftype' in kwargs else set('r')
title = kwargs['title'] if 'title' in kwargs else 'Please select a file.'
bundle_host = kwargs['bundle_host'] if 'bundle_host' in kwargs else None
extra_button = 1 if bundle_host else 0
for t in ftype:
assert t in type_check, "Invalid ftype: %s" % t
# This is a special case
if bundle_host and fname == os.sep:
return os.sep
default = os.getcwd() + os.sep
while 1:
if fname is not None:
if not os.path.exists(fname):
d.msgbox("The file `%s' you choose does not exist." % fname,
width=SMALL_WIDTH)
else:
mode = os.stat(fname).st_mode
for i in ftype:
if type_check[i](mode):