forum.vmspython.org Forum Index forum.vmspython.org
Forum system
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using Python to run accounting reports?

 
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> Python for OpenVMS
View previous topic :: View next topic  
Author Message
jescab



Joined: 28 Jan 2008
Posts: 254

PostPosted: Sat Nov 17, 2012 1:51 pm    Post subject: Using Python to run accounting reports? Reply with quote

Hi.
Has someone tried the definitions for the accounting file ?
That is, the "accdef" and "acrdef" modules?
Maybe even some short example? Smile
Jan-Erik.
Back to top
View user's profile Send private message
jfp



Joined: 12 Jul 2004
Posts: 636

PostPosted: Sat Nov 17, 2012 7:50 pm    Post subject: Reply with quote

Hi Jan-Erik

you can use the module vms.sysuaf

There is a small problem, mpdule name conflict (see vmspython history page).

So you will have to dowload the new LD image, currently only IA64, which included the fix.

On AXP just rename vms.construct into vms.vmsconstruct and update the file PYTHON_ROOT:[local.vms.rms]IndexedFile2.py: change vms.construct into vms.vmsconstruct.

JF
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jescab



Joined: 28 Jan 2008
Posts: 254

PostPosted: Sun Nov 18, 2012 1:44 am    Post subject: Reply with quote

That is, reading ACCOUNTNG.DAT, not SYSUAF.
Or does vms.sysuaf that also?
Back to top
View user's profile Send private message
jfp



Joined: 12 Jul 2004
Posts: 636

PostPosted: Sun Nov 18, 2012 9:46 am    Post subject: Reply with quote

Embarassed
You're correct, I read too fast the question...

I think that I have a example somewhere, I will take a look.

JF
Back to top
View user's profile Send private message Send e-mail Visit poster's website
tonymcg



Joined: 12 Jul 2011
Posts: 3
Location: Melbourne, Australia

PostPosted: Fri Nov 23, 2012 8:44 am    Post subject: Reply with quote

I was after a Python script to interrogate the ACCOUNTNG file too, I googled for an answer and found accountng.py here : http://hg.vmspython.org/vmspython/file/4b41453bb7cd/python/local/vms/

But I can't get it to work, I get...

    $ python ACCOUNTNG.PY
    Traceback (most recent call last):
    File "accountng.py", line 4, in <module>

    ImportError: cannot import name Record


I'm no python wizard, I cannot figure it out. Did an older version of IndexedFiles.py have a "Record" class that has since been removed? Is there a more recent version of accountng.py available?

Thanks,
Tony
Back to top
View user's profile Send private message
jescab



Joined: 28 Jan 2008
Posts: 254

PostPosted: Fri Nov 23, 2012 5:20 pm    Post subject: Reply with quote

I have used the current RMS interface in Python and it does look a little different.
I would also guess that the ACCOUNTNG.PY file was written against an older version of the RMS interface.
The file is not particular large, so I guess it would be possible to port it to the current RMS interface.
But first I'll wait a few days more for jfp to "take a look"... Smile

Jan-Erik.
Back to top
View user's profile Send private message
jfp



Joined: 12 Jul 2004
Posts: 636

PostPosted: Fri Nov 23, 2012 6:37 pm    Post subject: Reply with quote

I have start to write an example program
Just the beginning:

Code:
import os
from vms.acrdef import *
from construct import *
from vms.vmsconstruct import *

RecordAcc = Struct("RecordAcc",
    BitStruct('type',
        BitField('type', 7),            # packet type
        Flag('packet'),                 # must be False (0)
        Flag('customer'),
        BitField('version', 3),         # version of the record structure
        Nibble('subtype'),              #  type of process
    ),
    ULInt16('length'),                  # packet length
    VMSDateTime('systime'),             # event system time
#    ULInt64('systime'),                # event system time
    Field('data', lambda ctx: ctx.length - 12),
)

fd = os.open('SYS$MANAGER:ACCOUNTNG.DAT', os.O_RDONLY)

r = os.read(fd, 500)

while r != '':
   #  print len(r), repr(r)
    rp = RecordAcc.parse(r)
    print rp
    r = os.read(fd, 500)

os.close(fd)
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jescab



Joined: 28 Jan 2008
Posts: 254

PostPosted: Sat Nov 24, 2012 2:13 pm    Post subject: Reply with quote

Nice! Smile
I guess it works. I had to download the latest "200" kit to get "vmsconstruct".
Now it breaks because a "sharing violation" on the accountng file,
I have not found how to let Python open and read the active file.
I guess it is som e additional "share" flag on the os.open, but I can't find it.
Back to top
View user's profile Send private message
jfp



Joined: 12 Jul 2004
Posts: 636

PostPosted: Sun Nov 25, 2012 11:05 am    Post subject: Reply with quote

I have added to the repository the example.

I is not complete, not all record definitions are done, I will enhanced it later.

http://hg.vmspython.org/vmspython/file/tip/python/local/vms/accountng2.py

It work on my system without any access conflit.

JF
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jescab



Joined: 28 Jan 2008
Posts: 254

PostPosted: Sun Nov 25, 2012 3:11 pm    Post subject: Reply with quote

Works in my environment :
Code:

$ tcpip sh ver

  HP TCP/IP Services for OpenVMS Alpha Version V5.7 - ECO 3
  on an AlphaServer DS25 running OpenVMS V8.4   

$ python
Python 2.7.3+ (default, Apr 21 2012, 22:10:48) [DECC] on OpenVMS
Type "help", "copyright", "credits" or "license" for more information.
>>>

*if* I :
- Change "from vms.vmsconstruct import *" to "from vms.construct import *"
- run from a copy of the accounting file.
When runed from the currently active accounting file I get:
Code:

$ @ acc_rep2.com
Traceback (most recent call last):
  File "<stdin>", line 166, in <module>
  File "<stdin>", line 142, in test
OSError: [Errno 65535] file currently locked by another user: '/SYS$MANAGER/ACCOUNTNG.DAT'
$

[/list]
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> Python for OpenVMS All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group