Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jdl_creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
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
Rene Caspart
jdl_creator
Commits
76b8f0b3
Commit
76b8f0b3
authored
8 years ago
by
Frank Fischer
Browse files
Options
Downloads
Patches
Plain Diff
Directly use shutil and os to access filesystem
parent
6b4171ed
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
classes/JDLCreator.py
+13
-35
13 additions, 35 deletions
classes/JDLCreator.py
with
13 additions
and
35 deletions
classes/JDLCreator.py
+
13
−
35
View file @
76b8f0b3
...
...
@@ -382,34 +382,19 @@ class JDLCreator(object):
jdl_content
=
self
.
__get_JDL_content
()
if
hasattr
(
self
,
'
job_folder
'
):
command
=
"
mkdir -p
"
+
self
.
job_folder
os
.
system
(
command
)
command
=
"
mkdir -p
"
+
self
.
job_folder
+
"
/log
"
os
.
system
(
command
)
command
=
"
mkdir -p
"
+
self
.
job_folder
+
"
/out
"
os
.
system
(
command
)
command
=
"
mkdir -p
"
+
self
.
job_folder
+
"
/error
"
os
.
system
(
command
)
# "else" is not needed, since we start with default folder "."
os
.
makedirs
(
self
.
job_folder
,
exist_ok
=
True
)
os
.
makedirs
(
'
%s/log
'
%
self
.
job_folder
,
exist_ok
=
True
)
os
.
makedirs
(
'
%s/out
'
%
self
.
job_folder
,
exist_ok
=
True
)
os
.
makedirs
(
'
%s/error
'
%
self
.
job_folder
,
exist_ok
=
True
)
# copy script to folder
if
os
.
path
.
isfile
(
self
.
executable
):
command
=
"
cp
"
+
self
.
executable
+
"
"
+
self
.
job_folder
os
.
system
(
command
)
command
=
"
chmod +x
"
+
self
.
job_folder
+
"
/
"
+
self
.
executable
os
.
system
(
command
)
else
:
os
.
system
(
"
mkdir -p log
"
)
os
.
system
(
"
mkdir -p out
"
)
os
.
system
(
"
mkdir -p error
"
)
command
=
"
chmod +x
"
+
self
.
executable
os
.
system
(
command
)
if
os
.
path
.
isfile
(
self
.
executable
)
and
self
.
job_folder
!=
'
.
'
:
shutil
.
copy
(
self
.
executable
,
self
.
job_folder
)
# make sure the file is executable
os
.
chmod
(
'
%s/%s
'
%
(
self
.
job_folder
,
self
.
executable
),
stat
.
S_IXGRP
|
stat
.
S_IXGRP
|
stat
.
S_IXOTH
)
# create JDL file
if
len
(
self
.
job_folder
)
>
0
:
self
.
__JDLFilename
=
self
.
job_folder
+
'
/
'
else
:
self
.
__JDLFilename
=
""
self
.
__JDLFilename
+=
(
'
JDL_
'
+
str
(
self
.
executable
).
split
(
'
/
'
)[
-
1
].
rsplit
(
'
.
'
)[
0
])
self
.
__JDLFilename
=
'
%s/JDL_%s
'
%
(
self
.
job_folder
,
str
(
self
.
executable
).
split
(
'
/
'
)[
-
1
].
rsplit
(
'
.
'
)[
0
])
with
open
(
self
.
__JDLFilename
,
'
w
'
)
as
file
:
for
line
in
jdl_content
:
...
...
@@ -417,11 +402,7 @@ class JDLCreator(object):
file
.
write
(
line
)
# create argument list file
if
len
(
self
.
job_folder
)
>
0
:
arguments_filename
=
self
.
job_folder
+
'
/
'
else
:
arguments_filename
=
""
arguments_filename
+=
'
arguments.txt
'
arguments_filename
=
'
%s/arguments.txt
'
%
self
.
job_folder
with
open
(
arguments_filename
,
'
w
'
)
as
file
:
for
index
,
line
in
enumerate
(
self
.
arguments
):
...
...
@@ -430,9 +411,7 @@ class JDLCreator(object):
file
.
write
(
line
)
if
len
(
self
.
job_folder
)
>
0
:
print
(
"
wrote JDL file:
"
+
self
.
__JDLFilename
+
"
in folder
"
+
self
.
job_folder
)
else
:
print
(
"
wrote JDL file:
"
+
self
.
__JDLFilename
)
print
(
'
wrote JDL file: %s
'
%
self
.
__JDLFilename
)
def
Submit
(
self
,
exe
=
''
,
arguments
=
''
,
remove_after_start
=
True
):
###
...
...
@@ -466,5 +445,4 @@ class JDLCreator(object):
os
.
chdir
(
main_path
)
if
remove_after_start
is
True
:
command
=
"
rm
"
+
self
.
__JDLFilename
os
.
system
(
command
)
os
.
remove
(
self
.
__JDLFilename
)
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