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
4b6d82ec
Commit
4b6d82ec
authored
10 years ago
by
Nikos Skalkotos
Browse files
Options
Downloads
Patches
Plain Diff
Add a new "directory" type for sysprep params
parent
4ed15903
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_menu.py
+7
-3
7 additions, 3 deletions
image_creator/dialog_menu.py
image_creator/os_type/__init__.py
+16
-1
16 additions, 1 deletion
image_creator/os_type/__init__.py
with
23 additions
and
4 deletions
image_creator/dialog_menu.py
+
7
−
3
View file @
4b6d82ec
...
...
@@ -648,9 +648,13 @@ def update_sysprep_param(session, name):
param
=
image
.
os
.
sysprep_params
[
name
]
while
1
:
if
param
.
type
==
"
file
"
:
title
=
"
Please select a file to use for the `%s
'
parameter
"
%
name
value
=
select_file
(
d
,
ftype
=
"
br
"
,
title
=
title
)
if
param
.
type
in
(
"
file
"
,
"
dir
"
):
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
'
value
=
select_file
(
d
,
ftype
=
ftype
,
title
=
title
)
if
value
is
None
:
return
False
else
:
...
...
This diff is collapsed.
Click to expand it.
image_creator/os_type/__init__.py
+
16
−
1
View file @
4b6d82ec
...
...
@@ -88,7 +88,8 @@ class SysprepParam(object):
type_checker
=
{
"
posint
"
:
self
.
_check_posint
,
"
string
"
:
self
.
_check_string
,
"
file
"
:
self
.
_check_fname
}
"
file
"
:
self
.
_check_fname
,
"
dir
"
:
self
.
_check_dname
}
assert
type
in
type_checker
.
keys
(),
"
Invalid parameter type: %s
"
%
type
...
...
@@ -101,6 +102,7 @@ class SysprepParam(object):
self
.
_checker
=
type_checker
[
type
]
def
set_value
(
self
,
value
):
"""
Update the value of the parameter
"""
try
:
self
.
value
=
self
.
_checker
(
value
)
except
ValueError
as
e
:
...
...
@@ -144,6 +146,19 @@ class SysprepParam(object):
raise
ValueError
(
"
Invalid filename
"
)
def
_check_dname
(
self
,
value
):
"""
Check if the value is a valid directory
"""
value
=
str
(
value
)
if
len
(
value
)
==
0
:
return
""
import
os
if
os
.
path
.
isdir
(
value
):
return
value
raise
ValueError
(
"
Invalid dirname
"
)
def
add_sysprep_param
(
name
,
type
,
default
,
descr
):
"""
Decorator for __init__ that adds the definition for a system preparation
...
...
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