Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dtk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
dtk
dtk
Commits
8beec1e8
Commit
8beec1e8
authored
Nov 08, 2018
by
KLOCZKO Thibaud
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hotfix/1.6.2'
parents
c81b80b3
2fecb550
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
47 deletions
+42
-47
CHANGES.md
CHANGES.md
+2
-0
CMakeLists.txt
CMakeLists.txt
+1
-1
src/dtkScript/dtkScriptInterpreterPython.cpp
src/dtkScript/dtkScriptInterpreterPython.cpp
+35
-43
src/dtkScript/dtkScriptInterpreterPython.h
src/dtkScript/dtkScriptInterpreterPython.h
+4
-3
No files found.
CHANGES.md
View file @
8beec1e8
# ChangeLog
# ChangeLog
## version 1.6.2 - 2018-11-08
-
dtkScriptInterpreterPython enables release method (for real).
## version 1.6.1 - 2018-11-08
## version 1.6.1 - 2018-11-08
-
dtkScriptInterpreterPython enables release method.
-
dtkScriptInterpreterPython enables release method.
## version 1.6.0 - 2018-11-07
## version 1.6.0 - 2018-11-07
...
...
CMakeLists.txt
View file @
8beec1e8
...
@@ -24,7 +24,7 @@ project(dtk)
...
@@ -24,7 +24,7 @@ project(dtk)
set
(
dtk_VERSION_MAJOR 1
)
set
(
dtk_VERSION_MAJOR 1
)
set
(
dtk_VERSION_MINOR 6
)
set
(
dtk_VERSION_MINOR 6
)
set
(
dtk_VERSION_PATCH
1
)
set
(
dtk_VERSION_PATCH
2
)
set
(
dtk_VERSION
set
(
dtk_VERSION
${
dtk_VERSION_MAJOR
}
.
${
dtk_VERSION_MINOR
}
.
${
dtk_VERSION_PATCH
}
)
${
dtk_VERSION_MAJOR
}
.
${
dtk_VERSION_MINOR
}
.
${
dtk_VERSION_PATCH
}
)
...
...
src/dtkScript/dtkScriptInterpreterPython.cpp
View file @
8beec1e8
...
@@ -57,9 +57,9 @@ public:
...
@@ -57,9 +57,9 @@ public:
dtkScriptInterpreterPython
*
dtkScriptInterpreterPython
::
instance
(
void
)
dtkScriptInterpreterPython
*
dtkScriptInterpreterPython
::
instance
(
void
)
{
{
if
(
!
s_instance
)
if
(
!
s_instance
)
{
s_instance
=
new
dtkScriptInterpreterPython
;
s_instance
=
new
dtkScriptInterpreterPython
;
}
return
s_instance
;
return
s_instance
;
}
}
...
@@ -68,85 +68,82 @@ dtkScriptInterpreterPython *dtkScriptInterpreterPython::s_instance = nullptr;
...
@@ -68,85 +68,82 @@ dtkScriptInterpreterPython *dtkScriptInterpreterPython::s_instance = nullptr;
dtkScriptInterpreterPython
::
dtkScriptInterpreterPython
(
void
)
:
dtkScriptInterpreter
(),
d
(
new
dtkScriptInterpreterPythonPrivate
)
dtkScriptInterpreterPython
::
dtkScriptInterpreterPython
(
void
)
:
dtkScriptInterpreter
(),
d
(
new
dtkScriptInterpreterPythonPrivate
)
{
{
Py_Initialize
();
// PyRun_SimpleString(dtkScriptInterpreterPythonRedirector_declare.toUtf8().constData());
QString
paths
;
QSettings
settings
(
QSettings
::
IniFormat
,
QSettings
::
UserScope
,
"inria"
,
"dtk-script"
);
settings
.
beginGroup
(
"modules"
);
paths
=
settings
.
value
(
"path"
).
toString
();
settings
.
endGroup
();
PyRun_SimpleString
(
"import sys"
);
foreach
(
QString
path
,
paths
.
split
(
":"
,
QString
::
SkipEmptyParts
))
PyRun_SimpleString
(
QString
(
"sys.path.append('%1')"
).
arg
(
path
).
toUtf8
().
constData
());
}
}
dtkScriptInterpreterPython
::~
dtkScriptInterpreterPython
(
void
)
dtkScriptInterpreterPython
::~
dtkScriptInterpreterPython
(
void
)
{
{
Py_Finalize
();
delete
d
;
delete
d
;
d
=
nullptr
;
d
=
NULL
;
}
}
void
dtkScriptInterpreterPython
::
init
(
void
)
void
dtkScriptInterpreterPython
::
init
(
void
)
{
{
Py_Initialize
();
QSettings
settings
(
QSettings
::
IniFormat
,
QSettings
::
UserScope
,
"inria"
,
"dtk-script"
);
QSettings
settings
(
QSettings
::
IniFormat
,
QSettings
::
UserScope
,
"inria"
,
"dtk-script"
);
settings
.
beginGroup
(
"modules"
);
QString
paths
=
settings
.
value
(
"path"
).
toString
();
settings
.
endGroup
();
PyRun_SimpleString
(
"import sys"
);
auto
path_list
=
paths
.
split
(
":"
,
QString
::
SkipEmptyParts
);
for
(
QString
path
:
path_list
)
{
PyRun_SimpleString
(
qPrintable
(
QString
(
"sys.path.append('%1')"
).
arg
(
path
)));
}
settings
.
beginGroup
(
"init"
);
settings
.
beginGroup
(
"init"
);
QString
init
=
settings
.
value
(
"script"
).
toString
();
QString
init
=
settings
.
value
(
"script"
).
toString
();
settings
.
endGroup
();
settings
.
endGroup
();
if
(
!
init
.
isEmpty
())
{
if
(
!
init
.
isEmpty
())
{
PyRun_SimpleString
(
QString
(
"execfile('%1')"
).
arg
(
init
).
toUtf8
().
constData
(
));
PyRun_SimpleString
(
qPrintable
(
QString
(
"execfile('%1')"
).
arg
(
init
)
));
}
else
{
}
else
{
dtkWarn
()
<<
"no init function "
;
dtkWarn
()
<<
Q_FUNC_INFO
<<
"No init function"
;
}
}
}
}
void
dtkScriptInterpreterPython
::
release
(
void
)
{
Py_Finalize
();
}
QString
dtkScriptInterpreterPython
::
interpret
(
const
QString
&
command
,
int
*
stat
)
QString
dtkScriptInterpreterPython
::
interpret
(
const
QString
&
command
,
int
*
stat
)
{
{
QString
statement
=
command
;
QString
statement
=
command
;
if
(
command
.
endsWith
(
":"
))
{
if
(
command
.
endsWith
(
":"
))
{
if
(
!
d
->
buffer
.
isEmpty
())
if
(
!
d
->
buffer
.
isEmpty
())
{
d
->
buffer
.
append
(
"
\n
"
);
d
->
buffer
.
append
(
"
\n
"
);
}
d
->
buffer
.
append
(
command
);
d
->
buffer
.
append
(
command
);
return
QString
();
return
""
;
}
}
if
(
!
command
.
isEmpty
()
&&
command
.
startsWith
(
" "
))
{
if
(
!
command
.
isEmpty
()
&&
command
.
startsWith
(
" "
))
{
if
(
!
d
->
buffer
.
isEmpty
())
if
(
!
d
->
buffer
.
isEmpty
())
{
d
->
buffer
.
append
(
"
\n
"
);
d
->
buffer
.
append
(
"
\n
"
);
}
d
->
buffer
.
append
(
command
);
d
->
buffer
.
append
(
command
);
return
QString
();
return
""
;
}
}
if
(
command
.
isEmpty
()
&&
!
d
->
buffer
.
isEmpty
())
{
if
(
command
.
isEmpty
()
&&
!
d
->
buffer
.
isEmpty
())
{
if
(
!
d
->
buffer
.
isEmpty
())
if
(
!
d
->
buffer
.
isEmpty
())
{
d
->
buffer
.
append
(
"
\n
"
);
d
->
buffer
.
append
(
"
\n
"
);
}
statement
=
d
->
buffer
;
statement
=
d
->
buffer
;
d
->
buffer
.
clear
();
d
->
buffer
.
clear
();
}
}
if
(
statement
.
isEmpty
())
if
(
statement
.
isEmpty
())
{
return
""
;
return
QString
();
}
PyObject
*
module
=
PyImport_AddModule
(
"__main__"
);
PyObject
*
module
=
PyImport_AddModule
(
"__main__"
);
// PyRun_SimpleString(dtkScriptInterpreterPythonRedirector_define.toUtf8().constData());
switch
(
PyRun_SimpleString
(
qPrintable
(
statement
)))
{
switch
(
PyRun_SimpleString
(
statement
.
toUtf8
().
constData
()))
{
case
0
:
*
stat
=
Status_Ok
;
break
;
case
0
:
*
stat
=
Status_Ok
;
break
;
case
-
1
:
*
stat
=
Status_Error
;
break
;
case
-
1
:
*
stat
=
Status_Error
;
break
;
default:
break
;
default:
break
;
...
@@ -154,11 +151,6 @@ QString dtkScriptInterpreterPython::interpret(const QString& command, int *stat)
...
@@ -154,11 +151,6 @@ QString dtkScriptInterpreterPython::interpret(const QString& command, int *stat)
PyErr_Print
();
PyErr_Print
();
// PyObject *redtor = PyObject_GetAttrString(module, "redirector");
// PyObject *result = PyObject_GetAttrString(redtor, "data");
// return QString(PyString_AsString(result)).simplified();
return
QString
();
return
QString
();
}
}
...
...
src/dtkScript/dtkScriptInterpreterPython.h
View file @
8beec1e8
...
@@ -14,9 +14,9 @@
...
@@ -14,9 +14,9 @@
#pragma once
#pragma once
#include
"dtkScriptInterpreter.h"
#include
<dtkScriptExport>
class
dtkScriptInterpreterPythonPrivate
;
#include "dtkScriptInterpreter.h"
class
DTKSCRIPT_EXPORT
dtkScriptInterpreterPython
:
public
dtkScriptInterpreter
class
DTKSCRIPT_EXPORT
dtkScriptInterpreterPython
:
public
dtkScriptInterpreter
{
{
...
@@ -31,13 +31,14 @@ protected:
...
@@ -31,13 +31,14 @@ protected:
public
slots
:
public
slots
:
QString
interpret
(
const
QString
&
command
,
int
*
stat
);
QString
interpret
(
const
QString
&
command
,
int
*
stat
);
void
init
(
void
);
void
init
(
void
);
void
release
(
void
);
private:
private:
dtkScriptInterpreterPython
(
void
);
dtkScriptInterpreterPython
(
void
);
~
dtkScriptInterpreterPython
(
void
);
~
dtkScriptInterpreterPython
(
void
);
private:
private:
dtkScriptInterpreterPythonPrivate
*
d
;
class
dtkScriptInterpreterPythonPrivate
*
d
;
};
};
//
//
...
...
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