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
ce4885e1
Commit
ce4885e1
authored
2 years ago
by
Boman Romain
Browse files
Options
Downloads
Patches
Plain Diff
add external editor
parent
0595d1b9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#7087
passed
2 years ago
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
fossils.py
+73
-24
73 additions, 24 deletions
fossils.py
fossils.ui
+16
-2
16 additions, 2 deletions
fossils.ui
ui_fossils.py
+9
-1
9 additions, 1 deletion
ui_fossils.py
with
98 additions
and
27 deletions
fossils.py
+
73
−
24
View file @
ce4885e1
...
...
@@ -44,6 +44,24 @@ class Window(QWidget, Ui_Form):
if
pyfile
:
self
.
inpFileLineEdit
.
setText
(
QDir
.
toNativeSeparators
(
pyfile
))
def
on_inpFileEditPushButton_pressed
(
self
):
"""
Open input file with a text editor
"""
editors
=
[
"
C:/Program Files/Just Great Software/EditPad Pro 8/EditPadPro8.exe
"
,
"
C:/Windows/notepad.exe
"
]
for
editor
in
editors
:
if
os
.
path
.
isfile
(
editor
):
import
subprocess
subprocess
.
Popen
([
editor
,
self
.
inpFileLineEdit
.
text
()
])
break
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
())
...
...
@@ -98,11 +116,21 @@ def view_results():
gmsh
.
fltk
.
run
()
def
add_folder2path
(
folder
):
def
add_folder2p
yp
ath
(
folder
):
if
os
.
path
.
isdir
(
folder
):
print
(
f
'
{
folder
}
added to pythonpath
'
)
sys
.
path
.
append
(
folder
)
def
add_folder2path
(
folder
):
if
not
os
.
path
.
isdir
(
folder
):
return
import
platform
if
'
Windows
'
in
platform
.
uname
():
path
=
os
.
environ
[
'
PATH
'
].
split
(
'
;
'
)
path
.
insert
(
0
,
folder
)
os
.
environ
[
'
PATH
'
]
=
'
;
'
.
join
(
path
)
print
(
f
'
{
folder
}
added to PATH
'
)
def
setup_pythonpath
():
"""
setup PYTHONPATH
...
...
@@ -110,16 +138,49 @@ def setup_pythonpath():
# adds script folder to the pythonpath
thisdir
=
os
.
path
.
split
(
os
.
path
.
abspath
(
__file__
))[
0
]
thisdir
=
os
.
path
.
normcase
(
thisdir
)
add_folder2path
(
thisdir
)
add_folder2p
yp
ath
(
thisdir
)
# add binary dir to PYTHONPATH
pyexe
=
os
.
path
.
basename
(
sys
.
executable
)
print
(
f
'
pyexe =
{
pyexe
}
'
)
add_folder2path
(
os
.
path
.
join
(
thisdir
,
'
cxxfem
'
,
add_folder2p
yp
ath
(
os
.
path
.
join
(
thisdir
,
'
cxxfem
'
,
'
build
'
,
'
bin
'
))
# gcc/mingw
add_folder2path
(
os
.
path
.
join
(
thisdir
,
'
cxxfem
'
,
'
build
'
,
'
bin
'
,
'
Release
'
))
# msvc
add_folder2p
yp
ath
(
os
.
path
.
join
(
thisdir
,
'
cxxfem
'
,
'
build
'
,
'
bin
'
,
'
Release
'
))
# msvc
# allows this script to be run without setting env
add_folder2pypath
(
os
.
path
.
join
(
thisdir
,
'
lib
'
,
'
gmsh-sdk
'
,
'
lib
'
))
# msvc
add_folder2path
(
os
.
path
.
join
(
thisdir
,
'
lib
'
,
'
gmsh-sdk
'
,
'
bin
'
))
# gmsh
def
create_workspace
(
workspace
,
testname
):
"""
create workspace and chdir into it
"""
if
workspace
:
# workspace is given:
# => workspace + testname
common
=
os
.
path
.
basename
(
testname
)
resdir
=
common
.
replace
(
os
.
sep
,
"
_
"
)
resdir
,
ext
=
os
.
path
.
splitext
(
resdir
)
wdir
=
os
.
path
.
join
(
workspace
,
resdir
)
else
:
# workspace is not given:
# => current_folder + 'workspace' + testname
thisdir
=
os
.
path
.
normcase
(
os
.
getcwd
())
# print(f'testname={testname}')
# print(f'thisdir={thisdir}')
common
=
os
.
path
.
commonprefix
((
testname
,
thisdir
))
# print(f'common={common}')
resdir
=
testname
[
len
(
common
)
+
1
:].
replace
(
os
.
sep
,
"
_
"
)
resdir
,
ext
=
os
.
path
.
splitext
(
resdir
)
wdir
=
os
.
path
.
join
(
'
workspace
'
,
resdir
)
print
(
'
workspace =
'
,
wdir
)
# sys.exit()
if
not
os
.
path
.
isdir
(
wdir
):
os
.
makedirs
(
wdir
)
os
.
chdir
(
wdir
)
if
__name__
==
"
__main__
"
:
...
...
@@ -159,8 +220,11 @@ if __name__ == "__main__":
testname
=
win
.
inpFileLineEdit
.
text
()
gui
=
True
else
:
workspace
=
None
action
=
'
run
'
workspace
=
None
# use default
if
args
.
post
:
action
=
'
post
'
else
:
action
=
'
run
'
testname
=
os
.
path
.
abspath
(
args
.
file
)
gui
=
False
...
...
@@ -171,24 +235,9 @@ if __name__ == "__main__":
testname
=
os
.
path
.
normcase
(
testname
)
# F:/ => f:/ on Windows
print
(
f
'
testname =
{
testname
}
'
)
# create workspace
if
workspace
:
common
=
os
.
path
.
basename
(
testname
)
resdir
=
common
.
replace
(
os
.
sep
,
"
_
"
)
resdir
,
ext
=
os
.
path
.
splitext
(
resdir
)
wdir
=
os
.
path
.
join
(
workspace
,
resdir
)
else
:
common
=
os
.
path
.
commonprefix
((
testname
,
thisdir
+
os
.
sep
))
resdir
=
testname
[
len
(
common
):].
replace
(
os
.
sep
,
"
_
"
)
resdir
,
ext
=
os
.
path
.
splitext
(
resdir
)
wdir
=
os
.
path
.
join
(
'
workspace
'
,
resdir
)
print
(
'
workspace =
'
,
wdir
)
if
not
os
.
path
.
isdir
(
wdir
):
os
.
makedirs
(
wdir
)
os
.
chdir
(
wdir
)
create_workspace
(
workspace
,
testname
)
tee
=
cxxfem
.
Tee
(
'
stdout.txt
'
)
# split streams
tee
=
cxxfem
.
Tee
(
'
stdout.txt
'
)
# split streams
(stdout + logfile)
try
:
if
action
==
'
run
'
:
...
...
This diff is collapsed.
Click to expand it.
fossils.ui
+
16
−
2
View file @
ce4885e1
...
...
@@ -6,8 +6,8 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
827
</width>
<height>
1
2
4
</height>
<width>
708
</width>
<height>
1
5
4
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
...
...
@@ -33,6 +33,13 @@
</property>
</widget>
</item>
<item
row=
"0"
column=
"3"
>
<widget
class=
"QPushButton"
name=
"inpFileEditPushButton"
>
<property
name=
"text"
>
<string>
Edit
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"0"
>
<widget
class=
"QLabel"
name=
"wrksplabel"
>
<property
name=
"text"
>
...
...
@@ -50,6 +57,13 @@
</property>
</widget>
</item>
<item
row=
"1"
column=
"3"
>
<widget
class=
"QPushButton"
name=
"wrkspExplorePushButton"
>
<property
name=
"text"
>
<string>
Explore
</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
...
...
This diff is collapsed.
Click to expand it.
ui_fossils.py
+
9
−
1
View file @
ce4885e1
...
...
@@ -14,7 +14,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class
Ui_Form
(
object
):
def
setupUi
(
self
,
Form
):
Form
.
setObjectName
(
"
Form
"
)
Form
.
resize
(
827
,
1
2
4
)
Form
.
resize
(
708
,
1
5
4
)
self
.
verticalLayout
=
QtWidgets
.
QVBoxLayout
(
Form
)
self
.
verticalLayout
.
setObjectName
(
"
verticalLayout
"
)
self
.
gridLayout
=
QtWidgets
.
QGridLayout
()
...
...
@@ -28,6 +28,9 @@ class Ui_Form(object):
self
.
inpFilePushButton
=
QtWidgets
.
QPushButton
(
Form
)
self
.
inpFilePushButton
.
setObjectName
(
"
inpFilePushButton
"
)
self
.
gridLayout
.
addWidget
(
self
.
inpFilePushButton
,
0
,
2
,
1
,
1
)
self
.
inpFileEditPushButton
=
QtWidgets
.
QPushButton
(
Form
)
self
.
inpFileEditPushButton
.
setObjectName
(
"
inpFileEditPushButton
"
)
self
.
gridLayout
.
addWidget
(
self
.
inpFileEditPushButton
,
0
,
3
,
1
,
1
)
self
.
wrksplabel
=
QtWidgets
.
QLabel
(
Form
)
self
.
wrksplabel
.
setObjectName
(
"
wrksplabel
"
)
self
.
gridLayout
.
addWidget
(
self
.
wrksplabel
,
1
,
0
,
1
,
1
)
...
...
@@ -37,6 +40,9 @@ class Ui_Form(object):
self
.
wrkspPushButton
=
QtWidgets
.
QPushButton
(
Form
)
self
.
wrkspPushButton
.
setObjectName
(
"
wrkspPushButton
"
)
self
.
gridLayout
.
addWidget
(
self
.
wrkspPushButton
,
1
,
2
,
1
,
1
)
self
.
wrkspExplorePushButton
=
QtWidgets
.
QPushButton
(
Form
)
self
.
wrkspExplorePushButton
.
setObjectName
(
"
wrkspExplorePushButton
"
)
self
.
gridLayout
.
addWidget
(
self
.
wrkspExplorePushButton
,
1
,
3
,
1
,
1
)
self
.
verticalLayout
.
addLayout
(
self
.
gridLayout
)
self
.
horizontalLayout_2
=
QtWidgets
.
QHBoxLayout
()
self
.
horizontalLayout_2
.
setObjectName
(
"
horizontalLayout_2
"
)
...
...
@@ -60,7 +66,9 @@ class Ui_Form(object):
Form
.
setWindowTitle
(
_translate
(
"
Form
"
,
"
Form
"
))
self
.
inpFilelabel
.
setText
(
_translate
(
"
Form
"
,
"
input file
"
))
self
.
inpFilePushButton
.
setText
(
_translate
(
"
Form
"
,
"
...
"
))
self
.
inpFileEditPushButton
.
setText
(
_translate
(
"
Form
"
,
"
Edit
"
))
self
.
wrksplabel
.
setText
(
_translate
(
"
Form
"
,
"
workspace
"
))
self
.
wrkspPushButton
.
setText
(
_translate
(
"
Form
"
,
"
...
"
))
self
.
wrkspExplorePushButton
.
setText
(
_translate
(
"
Form
"
,
"
Explore
"
))
self
.
runPushButton
.
setText
(
_translate
(
"
Form
"
,
"
Run
"
))
self
.
viewPushButton
.
setText
(
_translate
(
"
Form
"
,
"
View
"
))
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