Ejemplo n.º 1
0
# binary tree search of data file for countrycode
#
# by Greg Hazel

import os
import mmap
import struct
import socket
import bisect

root, file = os.path.split(__file__)
addrmap = os.path.join(root, "addrmap.dat")
if not os.path.exists(addrmap):
    from BTL.platform import get_module_filename
    root, file = os.path.split(get_module_filename())
    addrmap = os.path.join(root, "addrmap.dat")
    if not os.path.exists(addrmap):
        addrmap = os.path.abspath("addrmap.dat")


### generates the addrmap file
##import ipfree
##f = open(addrmap, 'wb')
##for e in ipfree.addrmap:
##    # stupid 0 padded nonsense.
##    d = '.'.join([ str(int(i)) for i in e[0].split('.') ])
##    ip = socket.inet_aton(d)
##    f.write(ip + e[1])
##f.close()

def int_to_ip(i):
Ejemplo n.º 2
0
    wk = (o.dwPlatformId, o.dwMajorVersion, o.dwMinorVersion)
    if wh.has_key(wk):
        os_version = wh[wk]
    else:
        os_version = wh[max(wh.keys())]
        sys.stderr.write("Couldn't identify windows version: wk:%s, %s, "
                         "assuming '%s'\n" % (str(wk),
                                              str(win_version_num),
                                              os_version))
    del wh, wk

elif os_name == 'posix':
    os_version = os.uname()[0]

app_root = os.path.split(get_module_filename())[0]
doc_root = app_root
osx = False
if os.name == 'posix':
    if os.uname()[0] == "Darwin":
        doc_root = app_root = app_root.encode('utf8')
        if has_pyobjc:
            doc_root = NSBundle.mainBundle().resourcePath()
            osx = True

def calc_unix_dirs():
    appdir = '%s-%s' % (app_name, version)
    ip = os.path.join(efs2(u'share'), efs2(u'pixmaps'), appdir)
    dp = os.path.join(efs2(u'share'), efs2(u'doc'), appdir)
    lp = os.path.join(efs2(u'share'), efs2(u'locale'))
    return ip, dp, lp
Ejemplo n.º 3
0
                           0, 0, o.dwBuildNumber)

    wk = (o.dwPlatformId, o.dwMajorVersion, o.dwMinorVersion)
    if wh.has_key(wk):
        os_version = wh[wk]
    else:
        os_version = wh[max(wh.keys())]
        sys.stderr.write("Couldn't identify windows version: wk:%s, %s, "
                         "assuming '%s'\n" %
                         (str(wk), str(win_version_num), os_version))
    del wh, wk

elif os_name == 'posix':
    os_version = os.uname()[0]

app_root = os.path.split(get_module_filename())[0]
doc_root = app_root
osx = False
if os.name == 'posix':
    if os.uname()[0] == "Darwin":
        doc_root = app_root = app_root.encode('utf8')
        if has_pyobjc:
            doc_root = NSBundle.mainBundle().resourcePath()
            osx = True


def calc_unix_dirs():
    appdir = '%s-%s' % (app_name, version)
    ip = os.path.join(efs2(u'share'), efs2(u'pixmaps'), appdir)
    dp = os.path.join(efs2(u'share'), efs2(u'doc'), appdir)
    lp = os.path.join(efs2(u'share'), efs2(u'locale'))