Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
S
scom
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
SulinOS
scom
Commits
8d9306d3
Kaydet (Commit)
8d9306d3
authored
Agu 30, 2017
tarafından
Suleyman Poyraz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Basic type python porting
üst
d8232222
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
76 additions
and
76 deletions
+76
-76
__init__.py
api/comar/__init__.py
+10
-10
service.py
api/comar/service.py
+8
-8
utility.py
api/comar/utility.py
+3
-3
CMakeLists.txt
comar/CMakeLists.txt
+1
-1
bus.c
comar/src/bus.c
+1
-1
db.c
comar/src/db.c
+6
-6
loop.c
comar/src/loop.c
+3
-3
policy.c
comar/src/policy.c
+5
-5
pydbus.c
comar/src/pydbus.c
+13
-13
script.c
comar/src/script.c
+26
-26
No files found.
api/comar/__init__.py
Dosyayı görüntüle @
8d9306d3
...
...
@@ -31,8 +31,8 @@ class Call:
def
__getitem__
(
self
,
key
):
if
not
self
.
class_
:
raise
KeyError
,
"Package should be selected after class"
if
not
isinstance
(
key
,
basestring
):
raise
KeyError
(
"Package should be selected after class"
)
if
not
isinstance
(
key
,
str
):
raise
KeyError
return
Call
(
self
.
link
,
self
.
group
,
self
.
class_
,
key
)
...
...
@@ -51,14 +51,14 @@ class Call:
obj
=
self
.
link
.
bus
.
get_object
(
self
.
link
.
address
,
"/"
,
introspect
=
False
)
packages
=
obj
.
listModelApplications
(
"
%
s.
%
s"
%
(
self
.
group
,
self
.
class_
),
dbus_interface
=
self
.
link
.
interface
)
for
package
in
packages
:
yield
unicode
(
package
)
yield
str
(
package
)
def
call
(
self
,
*
args
,
**
kwargs
):
self
.
async
=
kwargs
.
get
(
"async"
,
None
)
self
.
quiet
=
kwargs
.
get
(
"quiet"
,
False
)
self
.
timeout
=
kwargs
.
get
(
"timeout"
,
120
)
if
self
.
async
and
self
.
quiet
:
raise
Exception
,
"async and quiet arguments can't be used together"
raise
Exception
(
"async and quiet arguments can't be used together"
)
if
self
.
async
or
self
.
quiet
:
if
self
.
package
:
obj
=
self
.
link
.
bus
.
get_object
(
self
.
link
.
address
,
"/package/
%
s"
%
self
.
package
)
...
...
@@ -119,14 +119,14 @@ class Call:
met
=
getattr
(
obj
,
self
.
method
)
try
:
return
met
(
dbus_interface
=
"
%
s.
%
s.
%
s"
%
(
self
.
link
.
interface
,
self
.
group
,
self
.
class_
),
timeout
=
self
.
timeout
,
*
args
)
except
dbus
.
DBusException
,
exception
:
except
dbus
.
DBusException
as
exception
:
if
"policy.auth"
in
exception
.
_dbus_error_name
or
"Comar.PolicyKit"
in
exception
.
_dbus_error_name
:
action
=
exception
.
get_dbus_message
()
if
self
.
queryPolicyKit
(
action
):
return
self
.
call
(
*
args
,
**
kwargs
)
raise
dbus
.
DBusException
,
exception
raise
dbus
.
DBusException
(
exception
)
else
:
raise
AttributeError
,
"Package name required for non-async calls."
raise
AttributeError
(
"Package name required for non-async calls."
)
def
queryPolicyKit
(
self
,
action
):
return
False
...
...
@@ -161,14 +161,14 @@ class Link:
code
=
code
.
split
(
"_"
)[
0
]
obj
=
self
.
bus
.
get_object
(
self
.
address
,
'/'
,
introspect
=
False
)
obj
.
setLocale
(
code
,
dbus_interface
=
self
.
interface
)
except
dbus
.
DBusException
,
exception
:
except
dbus
.
DBusException
as
exception
:
pass
def
cancel
(
self
,
method
=
"*"
):
try
:
obj
=
self
.
bus
.
get_object
(
self
.
address
,
'/'
,
introspect
=
False
)
return
obj
.
cancel
(
method
,
dbus_interface
=
self
.
interface
)
except
dbus
.
DBusException
,
exception
:
except
dbus
.
DBusException
as
exception
:
return
0
def
listRunning
(
self
,
all
=
True
):
...
...
@@ -176,7 +176,7 @@ class Link:
try
:
obj
=
self
.
bus
.
get_object
(
self
.
address
,
'/'
,
introspect
=
False
)
methods
=
obj
.
listRunning
(
all
,
dbus_interface
=
self
.
interface
)
except
dbus
.
DBusException
,
exception
:
except
dbus
.
DBusException
as
exception
:
return
methods
for
index
,
method
in
enumerate
(
methods
):
if
method
.
startswith
(
"
%
s."
%
self
.
interface
):
...
...
api/comar/service.py
Dosyayı görüntüle @
8d9306d3
...
...
@@ -120,14 +120,14 @@ def _getPid(pidfile):
"""Read process ID from a .pid file."""
try
:
pid
=
file
(
pidfile
)
.
read
()
except
IOError
,
e
:
except
IOError
as
e
:
if
e
.
errno
!=
2
:
raise
return
None
# Some services put custom data after the first line
pid
=
pid
.
split
(
"
\n
"
)[
0
]
.
strip
()
# Non-pid data is also seen when stopped state in some services :/
if
len
(
pid
)
==
0
or
len
(
filter
(
lambda
x
:
not
x
in
"0123456789"
,
pid
)
)
>
0
:
if
len
(
pid
)
==
0
or
len
(
[
x
for
x
in
pid
if
not
x
in
"0123456789"
]
)
>
0
:
return
None
return
int
(
pid
)
...
...
@@ -143,7 +143,7 @@ def _checkPid(pid, user_uid=None, command=None, name=None):
if
user_uid
:
try
:
st
=
os
.
stat
(
path
)
except
OSError
,
e
:
except
OSError
as
e
:
if
e
.
errno
!=
2
:
raise
return
False
...
...
@@ -153,7 +153,7 @@ def _checkPid(pid, user_uid=None, command=None, name=None):
if
command
:
try
:
cmdline
=
file
(
"
%
s/cmdline"
%
path
)
.
read
()
except
IOError
,
e
:
except
IOError
as
e
:
if
e
.
errno
!=
2
:
raise
return
False
...
...
@@ -162,7 +162,7 @@ def _checkPid(pid, user_uid=None, command=None, name=None):
elif
name
:
try
:
stats
=
file
(
"
%
s/stat"
%
path
)
.
read
()
except
IOError
,
e
:
except
IOError
as
e
:
if
e
.
errno
!=
2
:
raise
return
False
...
...
@@ -232,7 +232,7 @@ def startService(command, args=None, pidfile=None, makepid=False, nice=None, det
"""
cmd
=
[
command
]
if
args
:
if
isinstance
(
args
,
basestring
):
if
isinstance
(
args
,
str
):
args
=
shlex
.
split
(
args
)
cmd
.
extend
(
args
)
...
...
@@ -254,7 +254,7 @@ def startService(command, args=None, pidfile=None, makepid=False, nice=None, det
if
detach
:
# Set umask to a sane value
# (other and group has no write permission by default)
os
.
umask
(
022
)
os
.
umask
(
0
o
22
)
# Detach from controlling terminal
try
:
tty_fd
=
os
.
open
(
"/dev/tty"
,
os
.
O_RDWR
)
...
...
@@ -316,7 +316,7 @@ def stopService(pidfile=None, command=None, args=None, chuid=None, user=None, na
if
command
and
args
is
not
None
:
cmd
=
[
command
]
if
args
:
if
isinstance
(
args
,
basestring
):
if
isinstance
(
args
,
str
):
args
=
shlex
.
split
(
args
)
cmd
.
extend
(
args
)
...
...
api/comar/utility.py
Dosyayı görüntüle @
8d9306d3
...
...
@@ -41,7 +41,7 @@ def run(*cmd):
"""Run a command without running a shell"""
command
=
[]
if
len
(
cmd
)
==
1
:
if
isinstance
(
cmd
[
0
],
basestring
):
if
isinstance
(
cmd
[
0
],
str
):
command
=
cmd
[
0
]
.
split
()
else
:
command
=
cmd
[
0
]
...
...
@@ -78,9 +78,9 @@ class FileLock:
if
timeout
!=
-
1
:
_type
|=
fcntl
.
LOCK_NB
self
.
fd
=
os
.
open
(
self
.
filename
,
os
.
O_WRONLY
|
os
.
O_CREAT
,
0600
)
self
.
fd
=
os
.
open
(
self
.
filename
,
os
.
O_WRONLY
|
os
.
O_CREAT
,
0
o
600
)
if
self
.
fd
==
-
1
:
raise
IOError
,
"Cannot create lock file"
raise
IOError
(
"Cannot create lock file"
)
while
True
:
try
:
...
...
comar/CMakeLists.txt
Dosyayı görüntüle @
8d9306d3
...
...
@@ -5,7 +5,7 @@ PROJECT (comar)
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.6
)
# Python is required
FIND_PACKAGE
(
PythonLibs
)
FIND_PACKAGE
(
PythonLibs
3
)
FIND_PACKAGE
(
PkgConfig
)
PKG_CHECK_MODULES
(
DBUS REQUIRED dbus-1
)
...
...
comar/src/bus.c
Dosyayı görüntüle @
8d9306d3
...
...
@@ -303,7 +303,7 @@ bus_call(const char *path, const char *interface, const char *member, PyObject *
// setLocale first
PyObject
*
args
=
PyTuple_New
(
1
);
PyTuple_SetItem
(
args
,
0
,
Py
String
_FromString
(
lang
));
PyTuple_SetItem
(
args
,
0
,
Py
Bytes
_FromString
(
lang
));
PyObject
*
ret
=
bus_execute
(
conn
,
"/"
,
config_interface
,
"setLocale"
,
args
,
25
,
"s"
);
if
(
!
ret
)
{
...
...
comar/src/db.c
Dosyayı görüntüle @
8d9306d3
...
...
@@ -190,15 +190,15 @@ db_load_model(iks *xml, PyObject **py_models)
// First argument is type. 0 for methods, 1 for signals
if
(
iks_strcmp
(
iks_name
(
met
),
"method"
)
==
0
)
{
PyTuple_SetItem
(
py_tuple
,
0
,
Py
Int
_FromLong
((
long
)
0
));
PyTuple_SetItem
(
py_tuple
,
0
,
Py
Long
_FromLong
((
long
)
0
));
}
else
{
PyTuple_SetItem
(
py_tuple
,
0
,
Py
Int
_FromLong
((
long
)
1
));
PyTuple_SetItem
(
py_tuple
,
0
,
Py
Long
_FromLong
((
long
)
1
));
}
// Second argument is PolicyKit action ID
char
*
action_id
=
db_action_id
(
iface_name
,
met
);
PyTuple_SetItem
(
py_tuple
,
1
,
Py
String
_FromString
(
action_id
));
PyTuple_SetItem
(
py_tuple
,
1
,
Py
Bytes
_FromString
(
action_id
));
// Build argument lists
PyObject
*
py_args_in
=
PyList_New
(
0
);
...
...
@@ -215,14 +215,14 @@ db_load_model(iks *xml, PyObject **py_models)
else
if
(
iks_strcmp
(
iks_name
(
arg
),
"arg"
)
==
0
)
{
if
(
iks_strcmp
(
iks_name
(
met
),
"method"
)
==
0
)
{
if
(
iks_strcmp
(
iks_find_attrib
(
arg
,
"direction"
),
"out"
)
==
0
)
{
PyList_Append
(
py_args_out
,
Py
String
_FromString
(
iks_find_attrib
(
arg
,
"type"
)));
PyList_Append
(
py_args_out
,
Py
Bytes
_FromString
(
iks_find_attrib
(
arg
,
"type"
)));
}
else
{
PyList_Append
(
py_args_in
,
Py
String
_FromString
(
iks_find_attrib
(
arg
,
"type"
)));
PyList_Append
(
py_args_in
,
Py
Bytes
_FromString
(
iks_find_attrib
(
arg
,
"type"
)));
}
}
else
if
(
iks_strcmp
(
iks_name
(
met
),
"signal"
)
==
0
)
{
PyList_Append
(
py_args_out
,
Py
String
_FromString
(
iks_find_attrib
(
arg
,
"type"
)));
PyList_Append
(
py_args_out
,
Py
Bytes
_FromString
(
iks_find_attrib
(
arg
,
"type"
)));
}
}
}
...
...
comar/src/loop.c
Dosyayı görüntüle @
8d9306d3
...
...
@@ -73,7 +73,7 @@ message_execute(DBusMessage *msg, const char *app, const char *model, const char
char
*
signature
=
script_signature
(
model
,
method
,
1
);
if
(
PyDict_GetItemString
(
model_def
,
method
)
!=
Py_None
)
{
const
char
*
action_id
=
Py
String
_AsString
(
PyTuple_GetItem
(
method_def
,
1
));
const
char
*
action_id
=
Py
Bytes
_AsString
(
PyTuple_GetItem
(
method_def
,
1
));
const
char
*
sender
=
dbus_message_get_sender
(
my_proc
.
bus_msg
);
if
(
strcmp
(
action_id
,
""
)
!=
0
)
{
...
...
@@ -172,7 +172,7 @@ handle_core_message(DBusMessage *bus_msg, const char *path, const char *iface, c
}
}
log_debug
(
"Killed %d processes.
\n
"
,
total
);
bus_reply_object
(
bus_msg
,
Py
Int
_FromLong
((
long
)
total
),
"i"
);
bus_reply_object
(
bus_msg
,
Py
Long
_FromLong
((
long
)
total
),
"i"
);
}
else
if
(
strcmp
(
method
,
"listRunning"
)
==
0
)
{
int
i
;
...
...
@@ -181,7 +181,7 @@ handle_core_message(DBusMessage *bus_msg, const char *path, const char *iface, c
for
(
i
=
0
;
i
<
my_proc
.
nr_children
;
i
++
)
{
struct
ProcChild
*
child
=
&
my_proc
.
children
[
i
];
if
(
PyTuple_GetItem
(
py_args
,
0
)
==
Py_True
||
dbus_message_has_sender
(
child
->
bus_msg
,
sender
))
{
PyList_Append
(
py_list
,
Py
String
_FromFormat
(
"%s.%s"
,
dbus_message_get_interface
(
child
->
bus_msg
),
dbus_message_get_member
(
child
->
bus_msg
)));
PyList_Append
(
py_list
,
Py
Bytes
_FromFormat
(
"%s.%s"
,
dbus_message_get_interface
(
child
->
bus_msg
),
dbus_message_get_member
(
child
->
bus_msg
)));
}
}
bus_reply_object
(
bus_msg
,
py_list
,
"as"
);
...
...
comar/src/policy.c
Dosyayı görüntüle @
8d9306d3
...
...
@@ -68,19 +68,19 @@ policy_check(const char *sender, const char *action, int *result)
}
PyObject
*
subject
=
PyTuple_New
(
2
);
PyTuple_SetItem
(
subject
,
0
,
Py
String
_FromString
(
"system-bus-name"
));
PyTuple_SetItem
(
subject
,
0
,
Py
Bytes
_FromString
(
"system-bus-name"
));
PyObject
*
details
=
PyDict_New
();
PyDict_SetItemString
(
details
,
"name"
,
Py
String
_FromString
(
sender
));
PyDict_SetItemString
(
details
,
"name"
,
Py
Bytes
_FromString
(
sender
));
PyTuple_SetItem
(
subject
,
1
,
details
);
PyObject
*
details2
=
PyDict_New
();
PyObject
*
obj
=
PyTuple_New
(
5
);
PyTuple_SetItem
(
obj
,
0
,
subject
);
PyTuple_SetItem
(
obj
,
1
,
Py
String
_FromString
(
action
));
PyTuple_SetItem
(
obj
,
1
,
Py
Bytes
_FromString
(
action
));
PyTuple_SetItem
(
obj
,
2
,
details2
);
PyTuple_SetItem
(
obj
,
3
,
Py
Int
_FromLong
((
long
)
1
));
PyTuple_SetItem
(
obj
,
4
,
Py
String
_FromString
(
"abc"
));
PyTuple_SetItem
(
obj
,
3
,
Py
Long
_FromLong
((
long
)
1
));
PyTuple_SetItem
(
obj
,
4
,
Py
Bytes
_FromString
(
"abc"
));
PyObject
*
ret
=
bus_execute2
(
conn
,
"org.freedesktop.PolicyKit1"
,
"/org/freedesktop/PolicyKit1/Authority"
,
"org.freedesktop.PolicyKit1.Authority"
,
"CheckAuthorization"
,
obj
,
-
1
,
"(sa{sv})sa{ss}us"
);
...
...
comar/src/pydbus.c
Dosyayı görüntüle @
8d9306d3
...
...
@@ -40,13 +40,13 @@ get_obj_sign(PyObject *obj)
*
*/
if
(
Py
String
_Check
(
obj
)
||
PyUnicode_Check
(
obj
))
{
if
(
Py
Bytes
_Check
(
obj
)
||
PyUnicode_Check
(
obj
))
{
return
"s"
;
}
else
if
(
PyBool_Check
(
obj
))
{
return
"b"
;
}
else
if
(
Py
Int
_Check
(
obj
))
{
else
if
(
Py
Long
_Check
(
obj
))
{
return
"i"
;
}
else
if
(
PyLong_Check
(
obj
))
{
...
...
@@ -105,7 +105,7 @@ pydbus_export(DBusMessageIter *iter, PyObject *obj, char *signature)
for
(
i
=
0
;
i
<
PyTuple_Size
(
obj
);
i
++
)
{
PyObject
*
py_sign
=
PyList_GetItem
(
py_list
,
i
);
PyObject
*
py_item
=
PyTuple_GetItem
(
obj
,
i
);
if
(
pydbus_export_item
(
iter
,
py_item
,
Py
String
_AsString
(
py_sign
))
!=
0
)
{
if
(
pydbus_export_item
(
iter
,
py_item
,
Py
Bytes
_AsString
(
py_sign
))
!=
0
)
{
return
-
1
;
}
}
...
...
@@ -226,8 +226,8 @@ pydbus_export_item(DBusMessageIter *iter, PyObject *obj, char *signature)
e
=
dbus_message_iter_append_basic
(
iter
,
DBUS_TYPE_BOOLEAN
,
&
p
.
b
);
break
;
case
'n'
:
if
(
Py
Int
_Check
(
obj
))
{
p
.
i16
=
(
short
)
Py
Int
_AsLong
(
obj
);
if
(
Py
Long
_Check
(
obj
))
{
p
.
i16
=
(
short
)
Py
Long
_AsLong
(
obj
);
}
else
{
// TODO: Raise error
...
...
@@ -236,8 +236,8 @@ pydbus_export_item(DBusMessageIter *iter, PyObject *obj, char *signature)
e
=
dbus_message_iter_append_basic
(
iter
,
DBUS_TYPE_INT16
,
&
p
.
i16
);
break
;
case
'q'
:
if
(
Py
Int
_Check
(
obj
))
{
p
.
u16
=
(
unsigned
short
)
Py
Int
_AsLong
(
obj
);
if
(
Py
Long
_Check
(
obj
))
{
p
.
u16
=
(
unsigned
short
)
Py
Long
_AsLong
(
obj
);
}
else
{
// TODO: Raise error
...
...
@@ -246,8 +246,8 @@ pydbus_export_item(DBusMessageIter *iter, PyObject *obj, char *signature)
e
=
dbus_message_iter_append_basic
(
iter
,
DBUS_TYPE_UINT16
,
&
p
.
u16
);
break
;
case
'i'
:
if
(
Py
Int
_Check
(
obj
))
{
p
.
i32
=
(
int
)
Py
Int
_AsLong
(
obj
);
if
(
Py
Long
_Check
(
obj
))
{
p
.
i32
=
(
int
)
Py
Long
_AsLong
(
obj
);
}
else
{
// TODO: Raise error
...
...
@@ -256,8 +256,8 @@ pydbus_export_item(DBusMessageIter *iter, PyObject *obj, char *signature)
e
=
dbus_message_iter_append_basic
(
iter
,
DBUS_TYPE_INT32
,
&
p
.
i32
);
break
;
case
'u'
:
if
(
Py
Int
_Check
(
obj
))
{
p
.
u32
=
(
long
)
Py
Int
_AsLong
(
obj
);
if
(
Py
Long
_Check
(
obj
))
{
p
.
u32
=
(
long
)
Py
Long
_AsLong
(
obj
);
}
else
{
// TODO: Raise error
...
...
@@ -289,8 +289,8 @@ pydbus_export_item(DBusMessageIter *iter, PyObject *obj, char *signature)
e
=
dbus_message_iter_append_basic
(
iter
,
DBUS_TYPE_DOUBLE
,
&
p
.
d
);
break
;
case
's'
:
if
(
Py
String
_Check
(
obj
))
{
p
.
s
=
Py
String
_AsString
(
obj
);
if
(
Py
Bytes
_Check
(
obj
))
{
p
.
s
=
Py
Bytes
_AsString
(
obj
);
}
else
{
// TODO: Raise error
...
...
comar/src/script.c
Dosyayı görüntüle @
8d9306d3
...
...
@@ -106,7 +106,7 @@ script_signature(const char *model, const char *member, int direction)
PyObject
*
py_models
=
PyDict_GetItemString
(
py_core
,
"models"
);
PyObject
*
py_model
=
PyDict_GetItemString
(
py_models
,
model
);
PyObject
*
py_method
=
PyDict_GetItemString
(
py_model
,
member
);
PyObject
*
py_str
=
Py
String
_FromString
(
""
);
PyObject
*
py_str
=
Py
Bytes
_FromString
(
""
);
PyObject
*
py_list
;
if
(
direction
==
0
)
{
...
...
@@ -118,10 +118,10 @@ script_signature(const char *model, const char *member, int direction)
int
i
;
for
(
i
=
0
;
i
<
PyList_Size
(
py_list
);
i
++
)
{
Py
String
_Concat
(
&
py_str
,
PyList_GetItem
(
py_list
,
i
));
Py
Bytes
_Concat
(
&
py_str
,
PyList_GetItem
(
py_list
,
i
));
}
return
Py
String
_AsString
(
py_str
);
return
Py
Bytes
_AsString
(
py_str
);
}
//! Splits signature into atomic DBus object signatures
...
...
@@ -144,7 +144,7 @@ script_signature_each(const char *signature)
return
NULL
;
}
else
{
PyList_Append
(
py_list
,
Py
String
_FromString
(
sign
));
PyList_Append
(
py_list
,
Py
Bytes
_FromString
(
sign
));
}
dbus_free
(
sign
);
...
...
@@ -179,10 +179,10 @@ py_catch(char **eStr, char **vStr, int log)
return
;
}
*
eStr
=
Py
String
_AsString
(
PyObject_GetAttrString
(
py_type
,
"__name__"
));
*
eStr
=
Py
Bytes
_AsString
(
PyObject_GetAttrString
(
py_type
,
"__name__"
));
if
(
py_value
)
{
*
vStr
=
Py
String
_AsString
(
PyObject_Str
(
py_value
));
*
vStr
=
Py
Bytes
_AsString
(
PyObject_Str
(
py_value
));
}
if
(
log
==
0
)
{
...
...
@@ -195,9 +195,9 @@ py_catch(char **eStr, char **vStr, int log)
while
(
py_trace
!=
NULL
&&
py_trace
!=
Py_None
)
{
py_frame
=
PyObject_GetAttrString
(
py_trace
,
"tb_frame"
);
py_code
=
PyObject_GetAttrString
(
py_frame
,
"f_code"
);
log_error
(
" File %s, line %d, in %s()
\n
"
,
Py
String
_AsString
(
PyObject_GetAttrString
(
py_code
,
"co_filename"
)),
(
int
)
Py
Int
_AsLong
(
PyObject_GetAttrString
(
py_trace
,
"tb_lineno"
)),
Py
String
_AsString
(
PyObject_GetAttrString
(
py_code
,
"co_name"
)));
log_error
(
" File %s, line %d, in %s()
\n
"
,
Py
Bytes
_AsString
(
PyObject_GetAttrString
(
py_code
,
"co_filename"
)),
(
int
)
Py
Long
_AsLong
(
PyObject_GetAttrString
(
py_trace
,
"tb_lineno"
)),
Py
Bytes
_AsString
(
PyObject_GetAttrString
(
py_code
,
"co_name"
)));
py_trace
=
PyObject_GetAttrString
(
py_trace
,
"tb_next"
);
}
}
...
...
@@ -217,8 +217,8 @@ sender_language()
PyObject
*
py_locales
=
PyDict_GetItemString
(
py_core
,
"locales"
);
const
char
*
lang
;
if
(
PyDict_Contains
(
py_locales
,
Py
String
_FromString
(
sender
)))
{
lang
=
Py
String
_AsString
(
PyDict_GetItemString
(
py_locales
,
sender
));
if
(
PyDict_Contains
(
py_locales
,
Py
Bytes
_FromString
(
sender
)))
{
lang
=
Py
Bytes
_AsString
(
PyDict_GetItemString
(
py_locales
,
sender
));
}
else
{
lang
=
"en"
;
...
...
@@ -241,11 +241,11 @@ validate_model_member(const char *model, const char *member, int type)
*
*/
if
(
PyDict_Contains
(
PyDict_GetItemString
(
py_core
,
"models"
),
Py
String
_FromString
(
model
)))
{
if
(
PyDict_Contains
(
PyDict_GetItemString
(
py_core
,
"models"
),
Py
Bytes
_FromString
(
model
)))
{
PyObject
*
py_dict_model
=
PyDict_GetItemString
(
PyDict_GetItemString
(
py_core
,
"models"
),
model
);
if
(
PyDict_Contains
(
py_dict_model
,
Py
String
_FromString
(
member
)))
{
if
(
PyDict_Contains
(
py_dict_model
,
Py
Bytes
_FromString
(
member
)))
{
PyObject
*
py_tuple
=
PyDict_GetItemString
(
py_dict_model
,
member
);
if
(
Py
Int
_AsLong
(
PyTuple_GetItem
(
py_tuple
,
0
))
==
(
long
)
type
)
{
if
(
Py
Long
_AsLong
(
PyTuple_GetItem
(
py_tuple
,
0
))
==
(
long
)
type
)
{
return
0
;
}
}
...
...
@@ -258,7 +258,7 @@ static PyObject *
c_bus_path
(
PyObject
*
self
,
PyObject
*
args
)
{
const
char
*
path
=
dbus_message_get_path
(
my_proc
.
bus_msg
);
PyObject
*
py_str
=
Py
String
_FromString
(
path
);
PyObject
*
py_str
=
Py
Bytes
_FromString
(
path
);
Py_INCREF
(
py_str
);
return
py_str
;
}
...
...
@@ -268,7 +268,7 @@ static PyObject *
c_bus_interface
(
PyObject
*
self
,
PyObject
*
args
)
{
const
char
*
iface
=
dbus_message_get_interface
(
my_proc
.
bus_msg
);
PyObject
*
py_str
=
Py
String
_FromString
(
iface
);
PyObject
*
py_str
=
Py
Bytes
_FromString
(
iface
);
Py_INCREF
(
py_str
);
return
py_str
;
}
...
...
@@ -278,7 +278,7 @@ static PyObject *
c_bus_member
(
PyObject
*
self
,
PyObject
*
args
)
{
const
char
*
member
=
dbus_message_get_member
(
my_proc
.
bus_msg
);
PyObject
*
py_str
=
Py
String
_FromString
(
member
);
PyObject
*
py_str
=
Py
Bytes
_FromString
(
member
);
Py_INCREF
(
py_str
);
return
py_str
;
}
...
...
@@ -288,7 +288,7 @@ static PyObject *
c_bus_sender
(
PyObject
*
self
,
PyObject
*
args
)
{
const
char
*
sender
=
dbus_message_get_sender
(
my_proc
.
bus_msg
);
PyObject
*
py_str
=
Py
String
_FromString
(
sender
);
PyObject
*
py_str
=
Py
Bytes
_FromString
(
sender
);
Py_INCREF
(
py_str
);
return
py_str
;
}
...
...
@@ -302,7 +302,7 @@ c_package(PyObject *self, PyObject *args)
if
(
strncmp
(
path
,
"/package/"
,
strlen
(
"/package/"
))
==
0
)
{
const
char
*
app
=
strsub
(
path
,
strlen
(
"/package/"
),
strlen
(
path
));
if
(
strlen
(
app
)
>
0
)
{
return
Py
String
_FromString
(
app
);
return
Py
Bytes
_FromString
(
app
);
}
}
...
...
@@ -319,7 +319,7 @@ c_model(PyObject *self, PyObject *args)
if
(
strncmp
(
iface
,
config_interface
,
strlen
(
config_interface
))
==
0
)
{
const
char
*
model
=
strsub
(
iface
,
strlen
(
config_interface
)
+
1
,
strlen
(
iface
));
if
(
strlen
(
model
)
>
0
)
{
return
Py
String
_FromString
(
model
);
return
Py
Bytes
_FromString
(
model
);
}
}
...
...
@@ -338,9 +338,9 @@ c_i18n(PyObject *self, PyObject *args)
return
NULL
;
}
PyObject
*
py_lang
=
Py
String
_FromString
(
sender_language
());
PyObject
*
py_lang
=
Py
Bytes
_FromString
(
sender_language
());
if
(
!
PyDict_Contains
(
py_dict
,
py_lang
))
{
py_lang
=
Py
String
_FromString
(
"en"
);
py_lang
=
Py
Bytes
_FromString
(
"en"
);
}
if
(
PyDict_Contains
(
py_dict
,
py_lang
))
{
...
...
@@ -459,7 +459,7 @@ c_fail(PyObject *self, PyObject *args)
static
PyObject
*
c_cfg_datapath
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
py_str
=
Py
String
_FromString
(
config_dir_data
);
PyObject
*
py_str
=
Py
Bytes
_FromString
(
config_dir_data
);
Py_INCREF
(
py_str
);
return
py_str
;
}
...
...
@@ -477,7 +477,7 @@ c_cfg_modelbase(PyObject *self, PyObject *args)
static
PyObject
*
c_cfg_interface
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
py_str
=
Py
String
_FromString
(
config_interface
);
PyObject
*
py_str
=
Py
Bytes
_FromString
(
config_interface
);
Py_INCREF
(
py_str
);
return
py_str
;
}
...
...
@@ -533,7 +533,7 @@ py_execute(const char *app, const char *model, const char *method, PyObject *py_
py_module
=
PyImport_ImportModule
(
"sys"
);
py_dict
=
PyModule_GetDict
(
py_module
);
py_list
=
PyDict_GetItemString
(
py_dict
,
"path"
);
PyList_Insert
(
py_list
,
0
,
Py
String
_FromString
(
config_dir_modules
));
PyList_Insert
(
py_list
,
0
,
Py
Bytes
_FromString
(
config_dir_modules
));
// Put CSL methods into __builtin__
py_mod_builtin
=
PyImport_AddModule
(
"__builtin__"
);
...
...
@@ -624,7 +624,7 @@ py_execute(const char *app, const char *model, const char *method, PyObject *py_
else
{
// Check if PolicyKit action defined at runtime
if
(
PyObject_HasAttrString
(
py_func
,
"policy_action_id"
))
{
const
char
*
action_id
=
Py
String
_AsString
(
PyObject_GetAttrString
(
py_func
,
"policy_action_id"
));
const
char
*
action_id
=
Py
Bytes
_AsString
(
PyObject_GetAttrString
(
py_func
,
"policy_action_id"
));
const
char
*
sender
=
dbus_message_get_sender
(
my_proc
.
bus_msg
);
int
result
;
...
...
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