File: openTransaction.py

package info (click to toggle)
mobyle 1.5.5%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 8,288 kB
  • sloc: python: 22,709; makefile: 35; sh: 33; ansic: 10; xml: 6
file content (44 lines) | stat: -rwxr-xr-x 1,650 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
########################################################################################
#                                                                                      #
#   Author: Bertrand Neron                                                             #
#   Organization:'Biological Software and Databases' Group, Institut Pasteur, Paris.   #
#   Distributed under GPLv2 Licence. Please refer to the COPYING.LIB document.         #
#                                                                                      #
########################################################################################

import os
import sys
import errno

MOBYLEHOME = os.path.abspath( os.path.join( os.path.dirname( __file__ ) , "../../../" ) )
os.environ['MOBYLEHOME'] = MOBYLEHOME

if ( MOBYLEHOME ) not in sys.path:
    sys.path.append( MOBYLEHOME )
if ( os.path.join( MOBYLEHOME , 'Src' ) ) not in sys.path:    
    sys.path.append( os.path.join( MOBYLEHOME , 'Src' ) )

import Mobyle.Test.MobyleTest

from Mobyle.Transaction import Transaction


def openTransaction( path , type ):
    try:
        transaction = Transaction( path , type )
    except IOError , err:
        if err.errno == errno.EAGAIN:
            # the assertion is made on the return status if it True or False
            # EAGAIN = Resource temporarily unavailable
            sys.exit(errno.EAGAIN)
        else:
            import traceback
            print >> sys.stderr , traceback.print_exc()
            raise err
    transaction.commit()
    
    
if __name__ == '__main__':
    path = sys.argv[1]
    type = int( sys.argv[2])
    openTransaction( path , type)