Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
installsystems
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Seblu
installsystems
Commits
4b808eb0
Commit
4b808eb0
authored
13 years ago
by
Sebastien Luttringer
Browse files
Options
Downloads
Patches
Plain Diff
is new doesn't overwrite by default
is new have now an force option to overwrite existing images
parent
d489321f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/is
+3
-1
3 additions, 1 deletion
bin/is
installsystems/image.py
+22
-17
22 additions, 17 deletions
installsystems/image.py
with
25 additions
and
18 deletions
bin/is
+
3
−
1
View file @
4b808eb0
...
...
@@ -270,7 +270,7 @@ def c_new(parser, args):
'''
Create a new source image
'''
SourceImage
.
create
(
args
.
path
)
SourceImage
.
create
(
args
.
path
,
args
.
force
)
def
c_search
(
parser
,
args
):
'''
...
...
@@ -448,6 +448,8 @@ p_move.set_defaults(func=c_move)
# new command parser
p_new
=
subparsers
.
add_parser
(
"
new
"
,
help
=
c_new
.
__doc__
.
lower
())
p_new
.
add_argument
(
"
-f
"
,
"
--force
"
,
action
=
"
store_true
"
,
default
=
False
,
help
=
"
overwrite existing source image
"
)
p_new
.
add_argument
(
"
path
"
,
help
=
"
new image directory path
"
)
p_new
.
set_defaults
(
func
=
c_new
)
...
...
This diff is collapsed.
Click to expand it.
installsystems/image.py
+
22
−
17
View file @
4b808eb0
...
...
@@ -58,7 +58,7 @@ class SourceImage(Image):
'''
@classmethod
def
create
(
cls
,
path
):
def
create
(
cls
,
path
,
force
=
False
):
'''
Create an empty source image
'''
...
...
@@ -80,23 +80,28 @@ class SourceImage(Image):
# create example files
arrow
(
"
Creating examples
"
)
arrowlevel
(
1
)
# create dict of file to create
examples
=
{}
# create description example from template
examples
[
"
description
"
]
=
{
"
path
"
:
"
description
"
,
"
content
"
:
istemplate
.
description
}
# create changelog example from template
examples
[
"
changelog
"
]
=
{
"
path
"
:
"
changelog
"
,
"
content
"
:
istemplate
.
changelog
}
# create parser example from template
examples
[
"
parser
"
]
=
{
"
path
"
:
"
parser/01-parser.py
"
,
"
content
"
:
istemplate
.
parser
}
# create setup example from template
examples
[
"
setup
"
]
=
{
"
path
"
:
"
setup/01-setup.py
"
,
"
content
"
:
istemplate
.
setup
}
for
name
in
examples
:
try
:
arrow
(
"
Creating %s example
"
%
name
)
expath
=
os
.
path
.
join
(
path
,
examples
[
name
][
"
path
"
])
if
not
force
and
os
.
path
.
exists
(
expath
):
warn
(
"
%s already exists. Skipping!
"
%
expath
)
continue
open
(
expath
,
"
w
"
).
write
(
examples
[
name
][
"
content
"
])
except
Exception
as
e
:
raise
Exception
(
"
Unable to create example file: %s
"
%
e
)
try
:
# create description example from template
arrow
(
"
Creating description example
"
)
open
(
os
.
path
.
join
(
path
,
"
description
"
),
"
w
"
).
write
(
istemplate
.
description
)
# create changelog example from template
arrow
(
"
Creating description example
"
)
open
(
os
.
path
.
join
(
path
,
"
changelog
"
),
"
w
"
).
write
(
istemplate
.
changelog
)
# create parser example from template
arrow
(
"
Creating parser script example
"
)
open
(
os
.
path
.
join
(
parser_path
,
"
01-parser.py
"
),
"
w
"
).
write
(
istemplate
.
parser
)
# create setup example from template
arrow
(
"
Creating setup script example
"
)
open
(
os
.
path
.
join
(
setup_path
,
"
01-setup.py
"
),
"
w
"
).
write
(
istemplate
.
setup
)
except
Exception
as
e
:
raise
Exception
(
"
Unable to example file: %s
"
%
e
)
try
:
# setting rights on files in setup and parser
# setting executable rights on files in setup and parser
arrow
(
"
Setting executable rights on scripts
"
)
umask
=
os
.
umask
(
0
)
os
.
umask
(
umask
)
...
...
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