Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Tobias Langer
/
experiment
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b6cbbb24
authored
Oct 05, 2016
by
Tobias Langer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved absolute path calculation to highest level.
parent
74e18604
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
19 deletions
+10
-19
generate.py
+10
-19
No files found.
generate.py
View file @
b6cbbb24
...
@@ -46,9 +46,6 @@ def create_dir(filename):
...
@@ -46,9 +46,6 @@ def create_dir(filename):
Create the directory denoted by filename, if it doesn't exists. Ask for its
Create the directory denoted by filename, if it doesn't exists. Ask for its
removal if it exists.
removal if it exists.
"""
"""
cwd
=
os
.
getcwd
()
path
=
os
.
path
.
join
(
cwd
,
filename
)
try
:
try
:
os
.
makedirs
(
path
)
os
.
makedirs
(
path
)
except
FileExistsError
:
except
FileExistsError
:
...
@@ -58,18 +55,6 @@ def create_dir(filename):
...
@@ -58,18 +55,6 @@ def create_dir(filename):
os
.
makedirs
(
path
)
os
.
makedirs
(
path
)
return
True
return
True
def
copy_files
(
makefile
,
codefile
,
destination
):
"""
Populate the experiments directory with Makefile and Codefile.
"""
cwd
=
os
.
getcwd
()
target
=
os
.
path
.
join
(
cwd
,
destination
)
makefile_path
=
os
.
path
.
join
(
cwd
,
makefile
)
shutil
.
copyfile
(
makefile_path
,
os
.
path
.
join
(
target
,
'Makefile'
))
codefile_path
=
os
.
path
.
join
(
cwd
,
destination
)
shutil
.
copyfile
(
codefile_path
,
os
.
path
.
join
(
target
,
'experiment.cpp'
))
def
create_header
(
headerfile
,
tasks
,
destination
):
def
create_header
(
headerfile
,
tasks
,
destination
):
"""
"""
Create a header file for the experiment.
Create a header file for the experiment.
...
@@ -88,6 +73,8 @@ def main():
...
@@ -88,6 +73,8 @@ def main():
parser
.
add_argument
(
'cpp'
,
type
=
str
,
nargs
=
'?'
,
default
=
'./template/experiment.cpp'
,
help
=
'path to optional custom c++ implementation.'
)
parser
.
add_argument
(
'cpp'
,
type
=
str
,
nargs
=
'?'
,
default
=
'./template/experiment.cpp'
,
help
=
'path to optional custom c++ implementation.'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
cwd
=
os
.
getcwd
()
for
num
,
experiment_file
in
enumerate
(
args
.
description
):
for
num
,
experiment_file
in
enumerate
(
args
.
description
):
with
open
(
experiment_file
,
'r'
)
as
experiment_description
:
with
open
(
experiment_file
,
'r'
)
as
experiment_description
:
descr_json
=
experiment_description
.
read
()
descr_json
=
experiment_description
.
read
()
...
@@ -98,9 +85,11 @@ def main():
...
@@ -98,9 +85,11 @@ def main():
experiment
[
'name'
]),
experiment
[
'name'
]),
file
=
sys
.
stderr
)
file
=
sys
.
stderr
)
experiment_dir
=
os
.
path
.
join
(
cwd
,
experiment
[
'name'
])
# Create folder
# Create folder
print
(
'create folder'
)
print
(
'create folder'
)
if
not
create_dir
(
experiment
[
'name'
]
):
if
not
create_dir
(
experiment
_dir
):
print
(
'Skipping experiment '
,
experiment
[
'name'
],
file
=
sys
.
stderr
)
print
(
'Skipping experiment '
,
experiment
[
'name'
],
file
=
sys
.
stderr
)
continue
continue
...
@@ -109,13 +98,15 @@ def main():
...
@@ -109,13 +98,15 @@ def main():
# Add header
# Add header
print
(
'create header file'
)
print
(
'create header file'
)
create_header
(
parser
.
header
,
tasks
,
experiment
[
'name'
]
)
create_header
(
args
.
headerfile
,
experiment
,
experiment_dir
)
# Add makefile & c++ file
# Add makefile & c++ file
print
(
'add Makefile'
)
print
(
'add Makefile'
)
makefile_path
=
os
.
path
.
join
(
experiment_dir
,
'Makefile'
)
shutil
.
copyfile
(
args
.
makefile
,
makefile_path
)
print
(
'add C++ file'
)
print
(
'add C++ file'
)
cpp_file_path
=
os
.
path
.
join
(
experiment_dir
,
'experiment.cpp'
)
copy_files
(
args
.
makefile
,
args
.
cpp
,
experiment
[
'name'
]
)
shutil
.
copyfile
(
args
.
cpp
,
cpp_file_path
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment