Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
fossils
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
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
Boman Romain
fossils
Commits
5a978969
Commit
5a978969
authored
2 years ago
by
Boman Romain
Browse files
Options
Downloads
Patches
Plain Diff
better handling of workspace folder
parent
7bc1305b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#7113
passed
2 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fossils.py
+56
-15
56 additions, 15 deletions
fossils.py
with
56 additions
and
15 deletions
fossils.py
+
56
−
15
View file @
5a978969
...
...
@@ -33,30 +33,63 @@ class Window(QWidget, Ui_Form):
# read Qt settings for the application
settings
=
QSettings
()
# self.restoreGeometry(settings.value("Geometry", self.saveGeometry()))
self
.
inpFileLineEdit
.
setText
(
settings
.
value
(
"
inpFile
"
,
""
))
self
.
wrkspLineEdit
.
setText
(
settings
.
value
(
"
workspace
"
,
""
))
self
.
inpFileLineEdit
.
setText
(
settings
.
value
(
"
inpFile
"
,
self
.
default_inputfile
()
))
self
.
wrkspLineEdit
.
setText
(
settings
.
value
(
"
workspace
"
,
self
.
default_wrksp
()
))
self
.
action
=
'
cancelled
'
#iconfile = os.path.join('fossils.png')
self
.
setWindowIcon
(
QIcon
(
"
:/fossils.png
"
))
def
default_inputfile
(
self
):
testnames
=
[
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'
models
'
,
'
others
'
,
'
dolicorhynchops_10k.py
'
),
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'
models
'
,
'
dolicorhynchops
'
,
'
dolicorhynchops_10k.py
'
),
]
for
name
in
testnames
:
if
os
.
path
.
isfile
(
name
):
return
name
return
""
def
default_wrksp
(
self
):
for
key
in
[
'
USERPROFILE
'
,
'
HOME
'
]:
try
:
folder
=
os
.
environ
[
key
]
if
os
.
path
.
isdir
(
folder
):
return
os
.
path
.
join
(
folder
,
'
workspace
'
)
except
:
pass
return
""
def
on_runPushButton_pressed
(
self
):
# print("runPushButton...")
if
not
os
.
path
.
isfile
(
self
.
inpFileLineEdit
.
text
()):
QMessageBox
.
critical
(
self
,
"
Error
"
,
"
Input file does not exist!
"
)
return
if
not
os
.
path
.
isdir
(
self
.
wrkspLineEdit
.
text
()):
QMessageBox
.
critical
(
self
,
"
Error
"
,
"
Workspace does not exist!
"
)
return
reply
=
QMessageBox
.
question
(
self
,
'
Message
'
,
"
Workspace does not exist - do you want to continue?
"
,
QMessageBox
.
Yes
|
QMessageBox
.
No
,
QMessageBox
.
Yes
)
if
reply
==
QMessageBox
.
No
:
return
# wdir = build_workspace_name(self.wrkspLineEdit.text(), self.inpFileLineEdit.text())
# TODO: check whether files are already present - ask and delete them if necessary
self
.
action
=
'
run
'
self
.
close
()
def
on_viewPushButton_pressed
(
self
):
# print("viewPushButton...")
wdir
=
build_workspace_name
(
self
.
wrkspLineEdit
.
text
(),
self
.
inpFileLineEdit
.
text
())
if
not
os
.
path
.
isdir
(
wdir
):
QMessageBox
.
critical
(
self
,
"
Error
"
,
f
"
No results in
{
wdir
}
!
"
)
return
self
.
action
=
'
post
'
self
.
close
()
def
on_inpFilePushButton_pressed
(
self
):
# try to set a relevant starting folder
default
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'
models
'
)
...
...
@@ -86,22 +119,26 @@ class Window(QWidget, Ui_Form):
subprocess
.
Popen
([
editor
,
self
.
inpFileLineEdit
.
text
()
])
break
def
on_inpFileResetPushButton_pressed
(
self
):
self
.
inpFileLineEdit
.
setText
(
""
)
self
.
inpFileLineEdit
.
setText
(
self
.
default_inputfile
())
def
on_wrkspExplorePushButton_pressed
(
self
):
"""
Browse workspace folder with system explorer
"""
os
.
startfile
(
self
.
wrkspLineEdit
.
text
())
def
on_wrkspPushButton_pressed
(
self
):
dir
=
QFileDialog
.
getExistingDirectory
(
self
,
"
Select output folder
"
,
self
.
wrkspLineEdit
.
text
())
if
dir
:
self
.
wrkspLineEdit
.
setText
(
QDir
.
toNativeSeparators
(
dir
))
def
on_wrkspResetPushButton_pressed
(
self
):
self
.
wrkspLineEdit
.
setText
(
""
)
self
.
wrkspLineEdit
.
setText
(
self
.
default_wrksp
()
)
def
closeEvent
(
self
,
event
):
...
...
@@ -183,6 +220,7 @@ def add_folder2path(folder):
print
(
f
'
{
folder
}
added to PATH
'
)
# print(f"os.environ['PATH']={os.environ['PATH']}")
def
setup_pythonpath
():
"""
setup PYTHONPATH
"""
...
...
@@ -209,7 +247,7 @@ def setup_pythonpath():
# print(f'sys.path={sys.path}')
def
create
_workspace
(
workspace
,
testname
):
def
build
_workspace
_name
(
workspace
,
testname
):
"""
create workspace folder and chdir into it
"""
if
workspace
:
...
...
@@ -230,11 +268,9 @@ def create_workspace(workspace, testname):
resdir
=
testname
[
len
(
common
)
+
1
:].
replace
(
os
.
sep
,
"
_
"
)
resdir
,
ext
=
os
.
path
.
splitext
(
resdir
)
wdir
=
os
.
path
.
abspath
(
os
.
path
.
join
(
'
workspace
'
,
resdir
))
print
(
'
workspace =
'
,
wdir
)
# sys.exit()
if
not
os
.
path
.
isdir
(
wdir
):
os
.
makedirs
(
wdir
)
os
.
chdir
(
wdir
)
return
wdir
if
__name__
==
"
__main__
"
:
...
...
@@ -289,7 +325,12 @@ if __name__ == "__main__":
testname
=
os
.
path
.
normcase
(
testname
)
# F:/ => f:/ on Windows
print
(
f
'
testname =
{
testname
}
'
)
create_workspace
(
workspace
,
testname
)
wdir
=
build_workspace_name
(
workspace
,
testname
)
print
(
'
workspace =
'
,
wdir
)
# sys.exit()
if
not
os
.
path
.
isdir
(
wdir
):
os
.
makedirs
(
wdir
)
os
.
chdir
(
wdir
)
try
:
if
action
==
'
run
'
:
...
...
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