473,761 Members | 2,440 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with writing an interface for system() call...

hi ..

I was reading the tutorial "Extending and Embedding
the python interpreter" available with python ..

http://www.python.org/doc/2.2.3/ext/ext.html

As per given in the tutorial i created an interface to
the system() system call.

this is the code of my module
Code:
#include<Python .h>

static PyObject * spam_system(sel f,args)
{
PyObject * self;
PyObject * args;
char * command;
int sts;

if ( !PyArg_ParseTup le(args, "s" , &command))
return NULL;

sts = system(command) ;
return Py_BuildValue(" i",sts);
}

static PyMethodDef SpamMethods[] = {
{ "system", spam_system , METH_VARARGS,"E xecute a
shell command"},
{NULL,NULL,0,NU LL}
};

void initspam(void){
(void) Py_InitModule(" spam", SpamMethods);
}
int main(int argc,char **argv)
{
// Py_SetProgName( argv[0]);

/* I COMMENTED THE ABOVE CALL AS IT GAVE ME SOME WIERD
ERROR */

Py_Initialize() ;

initspam();
}

i was able to compile the above code using disutils
package available with python .

http://www.python.org/doc/2.2.3/ext/building.html

I was even able to import the module into the python
interpreter but caling the function gave me the
following error
Code:
import spam
spam.system( "ls -l")

python: Python/getargs.c:90: vgetargs1: Assertion
`compat || (args != (PyObject*)((vo id *)0))' failed.
Aborted
[haynes@fosters: ~/python]
whaaaaattttt??? ?

any idea?

thnks

Haynes Mathew
Send instant messages to your online friends http://in.messenger.yahoo.com
Jan 9 '06 #1
0 1256

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
367
by: Nadav | last post by:
Hi, Introduction: **************** I am writing a component based application, the application is built of several Native COM objects and some .NET classes exposed as COM objects by 'COM Interop', all of the objects expose an interface of the same type. Following are some important points to take in mind while reading this post: 1. The consumer of the interface/s is written in native code ( not ..NET*.* ) so COM interfaces are used for...
2
1738
by: Jeff Van Epps | last post by:
We've been unable to get events working going from C# to VJ++. We think that the C# component is being exposed properly as a ConnectionPoint, and the Advise() from the VJ++ side seems to be working, because the delegate on the C# side has 1 item in its invocation list after the Advise(). However when we try to make the callback, we get: System.NullReferenceException: Object reference not set to an instance of an object at...
0
3940
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header, example, and DLL:...
10
4029
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
7
5908
by: Desmond Cassidy | last post by:
Hi, I have being trying to get a grip of HTML data manipulation and am using the mshtml class and System.Net to retriver HTML pages. Now as far as I can see, one can read HTML in different ways. 1. Using the WebBrowser and loading the HTML into the mshtml.HTMLDocument class and then step through the various tags (input, a), tables etc. 2. Use System.Net.WebRequest/Response to load the data into a HTML string using a Stream Reader. Now...
10
2549
by: Bryce Calhoun | last post by:
Hello, First of all, this is a .NET 1.1 component I'm creating. SUMMARY ----------------------- This component that I'm creating is, for all intents and purposes, a document parser (I'm actually deserializing a SOAP document into an object and parsing out the fields, but that's fairly immaterial to this
0
2206
by: Slawomir Nasiadka | last post by:
Hi, I'am new to this group so I would like to say "Hello" everyone and here is my problem: I'm writing a simple application (code is at the end of this message) witch would list all mails from a directory from Outlook Express. I have: - OE 6.0 - .NET Framework 1.1 - interface definition language for OE 6.0 - msoeapi.idl
13
3837
by: rkausch | last post by:
Hello everyone, I'm writing because I'm frustrated with the implementation of C#'s generics, and need a workaround. I come from a Java background, and am currently writing a portion of an application that needs implementations in both Java and C#. I have the Java side done, and it works fantastic, and the C# side is nearly there. The problem I'm running into has to do with the differences in implementations of Generics between the two...
0
1366
by: krishnasamy | last post by:
Hello, I am writing a DLL for Capturing the Image from Camera Device using Camera SDK DLL. All the calls made to functions in Camera SDK DLL are working properly as I am able to get a return value of zero. I am able to get the image data as unmanaged memory address(pointer) as a result of a functions call to the camera SDK. I do not know how to display this data directly in the interface using the bitmap class without copying the same to...
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9336
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9948
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6603
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.