i need to get information about the processes running on a windows pc
(98, 2k, xp)
i can get the pid's using, win32process.EnumProcesses()...and I can get
a handle on a process using an id..such as
handle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION, 0,
pids[0])
..but how can i get
lt;
}
Is PyResult going to be de-referenced or handled automaticlly by python
in some way? Or, do I need to somehow call Py_DECREF(pyResult)
somewhere..if so, where/when?
Thanks!
Java and Swing wrote:
> I have been posting lately about writing a C wrapper so Python can
> access my
I have been posting lately about writing a C wrapper so Python can
access my C functions.
In my wrapper function I have something like...
static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
PyObject *data;
char *result;
long *d;
PyArg_ParseTuple(args, "O:wrap_doStuff"
I got it. I had get_long_array placed after the method that was
calling it..
i.e.
void doStuf(...) {
x = get_long_array(...);
}
static long *get_long_array(PyObject *data, int *data_size) {
...
}
...I put get_long_array before it in my code..and its fine.
Thanks
Java and Swing wrote
Fredrik,
...I tried using your code...
static long *get_long_array(PyObject *data, int *data_size) {
int i, size;
long* out;
PyObject* seq;
seq = PySequence_Fast(data, "expected a sequence");
if (!seq)
return NULL;
size = PySequence_Size(seq);
if (size < 0)
Fredrik...I forgot about that...wish Google Groups had a way to quickly
find the topics a user posts.
anyhow, for receiving an object from python..is it
ok = PyArg_ParseTuple(args, "sO", &x, &y);
...is it "sO" or "s0" is it O (as in the letter) or 0 (as in the
number)? I would think "O" the
I have a C function which takes an array of long values..
I understand that I can pass a tuple to a C wrapper function and in the
C wrapper function have..
int ok = PyArg_ParseTuple(args, "s(ll)", &a, &b, &c);
..that's great if my tuple only contained two longs..but what if it
contained 50
would
Bernhard Herzog wrote:
> "Java and Swing" <[EMAIL PROTECTED]> writes:
>
> > char *foo(const char *in) {
> > char *tmp;
> > tmp = (char *) malloc((strlen(in) * sizeof(char)) + 1);
> > strcpy(tmp, in);
> > ...
> > ...
>
have trouble.
Thanks in advance.
Bernhard Herzog wrote:
> "Java and Swing" <[EMAIL PROTECTED]> writes:
>
> > thanks for the tip, however even when I do not free aString or bString,
> > i'm still crashing at the malloc in the c function, not the wrapper.
>
&
thanks for the tip, however even when I do not free aString or bString,
i'm still crashing at the malloc in the c function, not the wrapper.
Bernhard Herzog wrote:
> "Java and Swing" <[EMAIL PROTECTED]> writes:
>
> > static PyObject *wrap_doStu
ideas why this is crashing when calling from Python via C
wrapper?
Java and Swing wrote:
> Sorry about the double post...
>
> anyhow, after putting in debug statements I found that it was crashing
> when it called, free(result)so I removed the free(result).
>
> now it crashes
Sorry about the double post...
anyhow, after putting in debug statements I found that it was crashing
when it called, free(result)so I removed the free(result).
now it crashes when it gets to, b = GetVal(bString, count(bString,
","));
..any ideas?
Java and Swing wrote:
> A
ff is a plain C function...nothing related to
Python.
Antoon Pardon wrote:
> Op 2005-10-12, Java and Swing schreef <[EMAIL PROTECTED]>:
> > static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
> > // this will store the result in a Python object
> >
ff is a plain C function...nothing related to
Python.
Antoon Pardon wrote:
> Op 2005-10-12, Java and Swing schreef <[EMAIL PROTECTED]>:
> > static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
> > // this will store the result in a Python object
> >
one more update...
if I remove PyMem_Free and free(...) ...so no memory clean up...I can
still only call doStuff 4 times, the 5th attemp crashes Python.
Java and Swing wrote:
> update:
> if I use C's free(result), free(a) free(b) instead of PyMem_Free...I
> only get one successfu
update:
if I use C's free(result), free(a) free(b) instead of PyMem_Free...I
only get one successfuly use/call of doStuff.
i.e.
// this works
doStuff(...)
// python crashes here
doStuff(...)
Java and Swing wrote:
> static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
>
Interesting...thanks. Any good tutorials out there, other than the
python doc for ext?
thanks.
Brandon K wrote:
> All the veteran programmers out there can correct me, but the way I did
> it in my extension was this:
>
> static PyObject *wrap_doNumberStuff(PyObject* self, PyObject* args)
> {
>
static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
// this will store the result in a Python object
PyObject *finalResult;
// get arguments from Python
char *result = 0;
char *in= 0;
char *aString = 0;
char *bString = 0;
Hi,
I have been posting about writing a C extension for Python...so far,
so good. At least for the "simple" functions that I need to wrap.
Ok, my c function looks like...
MY_NUM *doNumberStuff(const char *in, const char *x) { ... }
MY_NUM is defined as, typedef unsigned long MY_NUM; (not su
quick question...how about returning an array of longs? ..or in my
case I have a pointer to an array of longs.
Thanks
Carsten Haese wrote:
> On Tue, 2005-10-11 at 15:14, Java and Swing wrote:
> > Anyhow, I need PyBuildValue to work.
>
> Try Py_BuildValue.
>
> HT
Carsten..thanks so much...that was it! DUH!
Carsten Haese wrote:
> On Tue, 2005-10-11 at 15:14, Java and Swing wrote:
> > Anyhow, I need PyBuildValue to work.
>
> Try Py_BuildValue.
>
> HTH,
>
> Carsten Haese.
--
http://mail.python.org/mailman/listinfo/python-list
compiler gives two warnings, one of which is...
"warning C4013: 'PyBuildValue' undefined; assuming extern returning
int"
thanks.
>> from DLLTester import *
>> x = doStuff("1,2,3,4,5", ",")
>>
Java and Swing wrote:
> Fredrik,
>
ecuting link.exe.
Any ideas what's happening here?
DLLTester.dll - 2 error(s), 0 warning(s)
Fredrik Lundh wrote:
> Java and Swing wrote:
>
> > So is "module.c" a new C file or do I add it to my existing, myapp.c?
>
> it's a complete module. if you want it to do
gt;>)
c:\> python setup.py build_ext -i
..is that it? If so, then it's ok that I get those 2 errors when
trying to build in visual c++?
thanks
Robert Kern wrote:
> Java and Swing wrote:
>
> > When I compile, I get two warnings..which are ok. Then when I build my
> &
Diez, yes you were right! But I have other problems now.
I now have...
#include
#include
#include "Python.h"
int doStuff(const char *input, const char *d) {...}
static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
int result;
char *input = 0;
char *d = 0;
I am having trouble with a wrapper function...
My C code looks like
---
#include
#include
#include "Python.h"
int doStuff(const char *input, const char *d) {...}
PyObject *wrap_doStuff(PyObject *, PyObject *args) {
int result;
char *input = 0;
char *
would they go?
Thanks!
Java and Swing wrote:
> So is "module.c" a new C file or do I add it to my existing, myapp.c?
>
>
> Fredrik Lundh wrote:
> > >seq = PySequence_Fast(data, "expected a sequence");
> > >if (!seq)
> > >
So is "module.c" a new C file or do I add it to my existing, myapp.c?
Fredrik Lundh wrote:
> >seq = PySequence_Fast(data, "expected a sequence");
> >if (!seq)
> >return NULL;
>
> here's some more information on the PySequence_Fast API:
>
> http://www.effbot.org/zone/python-ca
I need to write an extension for a C function so that I can call it
from python.
C code (myapp.c)
==
typedef unsigned long MY_LONG;
char *DoStuff(char *input, MY_LONG *x) { ... }
so you pass in a string and an array of MY_LONGS...such as
MY_LONGS vals[10] = {};
char *input = "this is my
I am using SWIG to wrap a C application for use in Python.
C code
==
// returns a pointer to an array of long values in the string, "input"
// MY_DIGIT is a typedef such as, typedef unsigned long MY_DIGIT;
MY_DIGIT *Split(char *input) { ... }
..I build a DLL named, _MyApp.dll
SWIG interface
(reposting, i was just told how I should properly reply via
groups.google.com)
im sorry, why would it be md_ptr? what is md_ptr?
i tried..
%include cpointer.i
%pointer_functions(MY_DIGIT, digit_ptr)
ptr = new_digit_ptr()
doIt("a message", ptr)
...doesnt work..still needs a DIGIT **
Miki Tebek
im sorry, why would it be md_ptr? what is md_ptr?
i tried..
%include cpointer.i
%pointer_functions(MY_DIGIT, digit_ptr)
ptr = new_digit_ptr()
doIt("a message", ptr)
...doesnt work..still needs a DIGIT **
--
http://mail.python.org/mailman/listinfo/python-list
I've tried sending a email to the swig mailing list 3 times...but it
never seems to get it...not sure what is going on, still looking into
it. Until then...
I now have a C function such as...
int doIt(char *a, MY_DIGIT **digit) {
...
}
so I am trying to figure out how to pass in that "digit"
i dont have a myapp.pyd ...i have myapp.c, or are u suggesting I dump
the dll? or the swig generated python file?
the swig generated python file only has .py and .pyc.
--
http://mail.python.org/mailman/listinfo/python-list
doh! nevermind, my original output had e and d in it.
--
http://mail.python.org/mailman/listinfo/python-list
i tried...
>> from ctypes import *
>> myapp = cdll.LoadLibrary("c:\\myapp.dll")
>> dumpbin /exports myapp.pyd
i get, SyntaxError: invalid syntax with it pointing at the first "p" in
myapp.pyd.
--
http://mail.python.org/mailman/listinfo/python-list
i have printed out some numbers and they look like
10944800e
10952560d
...if i want to later assign this type of number to variable how can i
do it?
for example i can't do...
>> x = 10944800e
..since it says "invalid token" on the "e".
thanks.
--
http://mail.python.org/mailman/listinfo/pyth
Grant Edwards wrote:
> On 2005-10-04, Java and Swing <[EMAIL PROTECTED]> wrote:
> > ok i got ctypes...now i try
> >
> >>> from ctypes import *
> >>> myApp = CDLL("C:\\myapp.dll")
>
> I've never seen that sort of usage before. I don
ok i got ctypes...now i try
>> from ctypes import *
>> myApp = CDLL("C:\\myapp.dll")
..now how can I call functions on in myapp.dll? From the tutorial I am
not sure..i try, dir(cdll.myApp) and dir(myApp)..but don't see my
functions listed.
thanks
Grant Edwards wrote
Is there some other way, besides SWIG, which will allow me to call
functions inside an Ansi C DLL?
Example (C):
defs.h
---
typedef unsigned long MY_DIGIT;
myapp.c
-
#include "defs.h"
char *DoSomeStuff(char *input, MY_DIGIT *digits) {
...
}
..thats an example of somethi
When I try to print an object in Python, python.exe crashes. Below
are my files.
defs.h
--
typedef unsigned long MY_DIGIT;
myapp.c
---
I am trying to wrap some C code I have. Currently I have something
like...
defs.h
---
typedef unsigned long MY_DIGIT;
myapp.c
-
void MakeDigits(MY_DIGIT digits[]) {
}
char* GetString(char *inMessage, MY_DIGIT *digit) {
char *results;
...
...
return r
I have some output stored in a string that looks like..
>> x
'\x01\xee\x1eo\xc3+\x8b\x83\xfad\xf6E\xaa\x0ea/I\x96\x83\xf5G\xa3\rQ\xfcH\xee\r'
According to, http://docs.python.org/lib/typesseq-strings.html, this is
"Unsigned Hexidecimal (lowercase)". How can I get this into normal
Ascii so that
43 matches
Mail list logo