Marc,

there is a python module called pyars that covers most of the ARS API and CMDB 
functions.

http://sourceforge.net/projects/pyars/

We use it for automizing migration stuff for ARS and find it quite useful and 
stable.

Cheers
Dirk



-------- Original-Nachricht --------
Datum: Fri, 27 Oct 2006 23:47:14 -0500
Von: Marc Nations <[EMAIL PROTECTED]>
An: arslist@ARSLIST.ORG
Betreff: Newb needs API help...couple of questions

> Hello all,
> 
> For starters, I'm trying to integrate the Remedy API into a Python
> application. That is my ultimate goal. So if anyone has any experience
> with that or knows where some sample code is, I'd appreciate it. I'm
> going to use ctypes to make the dll calls and am building the
> structures.
> 
> However, I've hit a wall so far with Python so I decided to run some
> example code in C and follow the process. I don't understand what is
> happening here, so I'm hoping someone could explain it to me. I am
> running the example given in the Remedy API documentation (with a
> couple of small modifications):
> 
> Let me start off by saying that the code works, however almost
> seemingly by accident. The problem is when I step through it using
> Visual Studio, it doesn't respond like I thought it would. Here's the
> problem:
> 
> Right now I have the application set up to fail at the initialization
> stage. So at Step A (marked below) I should see a failure after the
> ARInitialization call is made. However that is not the case. Instead I
> get back a response of '0', and it does not fall into the exception
> loop.
> 
> Instead it moves on and attempts the ARGetListSchema call. At Step B is
> when the error for the initialization is actually recognized. So then
> it falls in the exception loop, prints out the error that was supposed
> to be printed in ARInit loop, and finishes execution.
> 
> This also means that the status list is not being freed like is
> supposed to happen during the FreeARStatusList proc. It's still there
> when the next function is called.
> 
> So in the end the application does work, but it's not failing at the
> correct place. So until I understand how this is supposed to properly
> work, there's no way I'll be able to get it interfaced over to another
> language. Does anyone know what either I or it is doing wrong?
> 
> Thanks,
> Marc
> 
> 
> // ARS.cpp : Defines the entry point for the console application.
> //
> 
> #include "stdafx.h"
> 
> #include "ar.h"
> #include "arextern.h"
> #include "arfree.h"
> 
> void printStatusList(ARStatusList *theList)
> {
>        unsigned int i;
>        for (i=0; i< theList -> numItems; i++)
>        {
>                if (theList -> statusList[i].appendedText == NULL ||
>                        theList -> statusList[i].appendedText == '\0')
>                        printf("%s", theList -> statusList[i].messageText);
>                else
>                        printf("%s:%s", theList ->
> statusList[i].messageText,
>                                theList -> statusList[i].appendedText);
>                        printf("(ARERR %d)\n", theList ->
> statusList[i].messageNum);
>                        printf("(Type %d)\n", theList ->
> statusList[i].messageType);
>        }
> }
> 
> int main(void)
> {
>        ARControlStruct control =
> {0,0,"TEST_REMEDY","TEST_REMEDY02","",0,"","TSTREMEDY01"};
>        ARNameList formNameList;
>        unsigned int i;
>        unsigned int ARInt;
>        unsigned int ARGetInt;
>        ARStatusList status;
> 
>        ARInt = ARInitialization(&control, &status);
> 
> ----------------------------------------------------------STEP
> A--------------------------------------------
> 
>        printf("(ARInt %d)\n", ARInt);
> 
>        if ( ARInt >= AR_RETURN_ERROR)
>        {
>                printStatusList(&status);
>                FreeARStatusList(&status, FALSE);
>                return 1;
>        }
> 
>        FreeARStatusList(&status, FALSE);
> 
> 
>        ARGetInt = ARGetListSchema(&control, 0,
>                                AR_LIST_SCHEMA_ALL|AR_HIDDEN_INCREMENT,
>                                NULL,NULL,
>                                &formNameList, &status);
> 
> ----------------------------------------------------------STEP
> B--------------------------------------------
> 
>        if(ARGetInt >= AR_RETURN_ERROR)
>                printStatusList(&status);
>        else
>        {
>                for (i=0; i<formNameList.numItems; i++)
>                        printf("%s\n",formNameList.nameList[i]);
>        }
> 
>        FreeARStatusList(&status, FALSE);
>        FreeARNameList(&formNameList, FALSE);
>        if(ARTermination(&control,&status) >= AR_RETURN_ERROR)
>                printStatusList(&status);
>        FreeARStatusList(&status, FALSE);
> }
> 
> _______________________________________________________________________________
> UNSUBSCRIBE or access ARSlist Archives at www.arslist.org ARSlist:"Where
> the Answers Are"

_______________________________________________________________________________
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org ARSlist:"Where the 
Answers Are"

Reply via email to