File: setup-check.py

package info (click to toggle)
pybliographer 1.2.9-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,528 kB
  • ctags: 1,399
  • sloc: python: 9,788; xml: 2,573; makefile: 609; sh: 597
file content (127 lines) | stat: -rw-r--r-- 2,888 bytes parent folder | download | duplicates (2)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# -*- coding: utf-8 -*-

import sys, string, re, traceback, os

base_version = string.split (sys.version) [0]
base_version = re.match ('[\d\.]+', base_version).group (0)

version = map (int, string.split (base_version, '.'))
if len (version) < 3: version.append (0)
fd = open ('conftest.out', 'w')
fd.write ('Python_Version=%s\n' % base_version)
fd.write ('Python_Major_Version=%d\n' % version [0])
fd.write ('Python_Minor_Version=%d\n' % version [1])
fd.write ('Python_Micro_Version=%d\n' % version [2])
fd.write ('Python_Prefix="%s"\n' % sys.exec_prefix)
fd.close ()


def error (msg):
    fd = open ('conftest.out', 'a')
    fd.write ('Status="%s"\n' % msg)
    fd.close ()

    sys.exit (1)

def warning (msg):
    fd = open ('conftest.out', 'a')
    fd.write ('Status="%s"\n' % msg)
    fd.close ()
    
    return


testversion = map (int, string.split (sys.argv [1], '.'))
if len (testversion) < 3: testversion.append (0)

for pair in map (None, version, testversion):
    if pair [0] > pair [1]: break
    
    if pair [0] < pair [1]:
        error ('requested version for python is %s, but I detected %s' % (
            sys.argv [1], sys.version))
        
# check for gtk and gnome 2.0
err = None

try:
    import pygtk
	
    pygtk.require ('2.0')
    
    import gnome, gtk
    import gtk.glade
    import gnome.ui
    import gconf

    v = string.join (map (str, gtk.pygtk_version), '.')

    if gtk.pygtk_version < (2,4,0):
        error ('requested version for PyGtk is %s, but I detected %s' % ('2.4.0', v))
    
    fd = open ('conftest.out', 'a')
    fd.write ('PyGtk_Version="%s"\n' % v)
    fd.close ()

    
except ImportError, msg:

    error ('error in python modules dependencies: %s' % msg)

except AssertionError, msg:

    error ('gtk problem: %s' % msg)

except RuntimeError, msg:

    if os.environ.get ('DISPLAY', '') != '':

        etype, value, tb = sys.exc_info ()
        traceback.print_exception (etype, value, tb)

        error ('unexpected runtime error')

    warning ('cannot test gtk [no DISPLAY]')

except:
    etype, value, tb = sys.exc_info ()
    traceback.print_exception (etype, value, tb)

    error ('unexpected error')

else:
    if gtk.pygtk_version < (2,4,0):
        error ('requested version for PyGtk is %s, but I detected %s' % ('2.4.0', v))


try:
    import _recode
    import _bibtex

    rq = _recode.request ('latin1..latex')

    l = 'abcd'
    c = _recode.recode (rq, l)

    if l != c:
        error ('broken recode version')

except ImportError, msg:

    error ('error in python modules dependencies: %s' % msg)

try:
    _bibtex.next_unfiltered

except AttributeError, msg:

    error ('Error in python-bibtex module: required function »next_unfiltered« missing: %s'
	   % msg)
    
except:
    etype, value, tb = sys.exc_info ()
    traceback.print_exception (etype, value, tb)

    error ('unexpected error')