Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
e9d4a81c
Commit
e9d4a81c
authored
11 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
treat .exe like .py
parent
64b70a24
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Common/OS.cpp
+20
-12
20 additions, 12 deletions
Common/OS.cpp
Common/OpenFile.cpp
+4
-4
4 additions, 4 deletions
Common/OpenFile.cpp
with
24 additions
and
16 deletions
Common/OS.cpp
+
20
−
12
View file @
e9d4a81c
...
@@ -213,7 +213,7 @@ int KillProcess(int pid)
...
@@ -213,7 +213,7 @@ int KillProcess(int pid)
int
SystemCall
(
const
std
::
string
&
command
,
bool
blocking
)
int
SystemCall
(
const
std
::
string
&
command
,
bool
blocking
)
{
{
// separate executable from arguments
// separate
(potential)
executable from arguments
std
::
string
exe
,
args
;
std
::
string
exe
,
args
;
std
::
string
::
size_type
pos
=
command
.
find_first_of
(
" "
);
std
::
string
::
size_type
pos
=
command
.
find_first_of
(
" "
);
if
(
pos
!=
std
::
string
::
npos
){
if
(
pos
!=
std
::
string
::
npos
){
...
@@ -226,15 +226,19 @@ int SystemCall(const std::string &command, bool blocking)
...
@@ -226,15 +226,19 @@ int SystemCall(const std::string &command, bool blocking)
// get executable extension
// get executable extension
std
::
vector
<
std
::
string
>
split
=
SplitFileName
(
exe
);
std
::
vector
<
std
::
string
>
split
=
SplitFileName
(
exe
);
// do we try to run a python script?
// do we try to run a .py script or a .exe?
bool
script
=
(
split
[
2
]
==
".py"
||
split
[
2
]
==
".PY"
);
bool
isPython
=
(
split
[
2
]
==
".py"
||
split
[
2
]
==
".PY"
);
if
(
script
&&
StatFile
(
exe
)){
bool
isExe
=
(
split
[
2
]
==
".exe"
||
split
[
2
]
==
".EXE"
);
Msg
::
Error
(
"Unable to open file '%s'"
,
exe
.
c_str
());
return
1
;
if
(
isPython
||
isExe
){
if
(
StatFile
(
exe
)){
Msg
::
Error
(
"Unable to open file '%s'"
,
exe
.
c_str
());
return
1
;
}
}
}
#if defined(WIN32)
#if defined(WIN32)
if
(
script
){
if
(
isPython
){
Msg
::
Info
(
"Shell opening '%s' with arguments '%s'"
,
exe
.
c_str
(),
Msg
::
Info
(
"Shell opening '%s' with arguments '%s'"
,
exe
.
c_str
(),
args
.
c_str
());
args
.
c_str
());
ShellExecute
(
NULL
,
(
char
*
)
"open"
,
(
char
*
)
exe
.
c_str
(),
ShellExecute
(
NULL
,
(
char
*
)
"open"
,
(
char
*
)
exe
.
c_str
(),
...
@@ -257,8 +261,8 @@ int SystemCall(const std::string &command, bool blocking)
...
@@ -257,8 +261,8 @@ int SystemCall(const std::string &command, bool blocking)
CloseHandle
(
prInfo
.
hThread
);
CloseHandle
(
prInfo
.
hThread
);
}
}
else
{
else
{
// DETACHED_PROCESS removes the console (useful if the program to launch
is
// DETACHED_PROCESS removes the console (useful if the program to launch
// a console-mode exe)
//
is
a console-mode exe)
CreateProcess
(
NULL
,
(
char
*
)
command
.
c_str
(),
NULL
,
NULL
,
FALSE
,
CreateProcess
(
NULL
,
(
char
*
)
command
.
c_str
(),
NULL
,
NULL
,
FALSE
,
NORMAL_PRIORITY_CLASS
|
DETACHED_PROCESS
,
NULL
,
NULL
,
NORMAL_PRIORITY_CLASS
|
DETACHED_PROCESS
,
NULL
,
NULL
,
&
suInfo
,
&
prInfo
);
&
suInfo
,
&
prInfo
);
...
@@ -266,10 +270,14 @@ int SystemCall(const std::string &command, bool blocking)
...
@@ -266,10 +270,14 @@ int SystemCall(const std::string &command, bool blocking)
}
}
#else
#else
std
::
string
cmd
(
command
);
std
::
string
cmd
(
command
);
if
(
script
){
if
(
isPython
||
isExe
){
if
(
access
(
exe
.
c_str
(),
X_OK
)){
if
(
access
(
exe
.
c_str
(),
X_OK
)){
Msg
::
Info
(
"Script '%s' is not executable: running with python"
,
exe
.
c_str
());
if
(
isPython
){
cmd
=
"python "
+
cmd
;
Msg
::
Info
(
"Script '%s' is not executable: running with python"
,
exe
.
c_str
());
cmd
=
"python "
+
cmd
;
}
else
Msg
::
Warning
(
"File '%s' is not executable"
,
exe
.
c_str
());
}
}
else
if
(
split
[
0
].
empty
()){
else
if
(
split
[
0
].
empty
()){
// workaround if pwd is not in PATH
// workaround if pwd is not in PATH
...
...
This diff is collapsed.
Click to expand it.
Common/OpenFile.cpp
+
4
−
4
View file @
e9d4a81c
...
@@ -412,16 +412,16 @@ int MergeFile(const std::string &fileName, bool warnIfMissing)
...
@@ -412,16 +412,16 @@ int MergeFile(const std::string &fileName, bool warnIfMissing)
}
}
#endif
#endif
#if defined(HAVE_ONELAB)
#if defined(HAVE_ONELAB)
else
if
(
ext
==
".pro"
){
else
if
(
ext
==
".pro"
||
ext
==
".PRO"
){
int
num
=
defineSolver
(
"GetDP"
);
int
num
=
defineSolver
(
"GetDP"
);
std
::
vector
<
std
::
string
>
split
=
SplitFileName
(
fileName
);
GModel
::
current
()
->
setName
(
split
[
1
]
+
".geo"
);
GModel
::
current
()
->
setName
(
split
[
1
]
+
".geo"
);
GModel
::
current
()
->
setFileName
(
split
[
0
]
+
split
[
1
]
+
".geo"
);
GModel
::
current
()
->
setFileName
(
split
[
0
]
+
split
[
1
]
+
".geo"
);
CTX
::
instance
()
->
launchSolverAtStartup
=
num
;
CTX
::
instance
()
->
launchSolverAtStartup
=
num
;
return
1
;
return
1
;
}
}
else
if
(
ext
==
".py"
){
else
if
(
ext
==
".py"
||
ext
==
".PY"
||
int
num
=
defineSolver
(
"python"
);
ext
==
".exe"
||
ext
==
".EXE"
){
int
num
=
defineSolver
(
split
[
1
]);
opt_solver_executable
(
num
,
GMSH_SET
,
fileName
);
opt_solver_executable
(
num
,
GMSH_SET
,
fileName
);
CTX
::
instance
()
->
launchSolverAtStartup
=
num
;
CTX
::
instance
()
->
launchSolverAtStartup
=
num
;
return
1
;
return
1
;
...
...
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