示例#1
0
            if mention:
                print "Using help file from " + p
            return j(p, "bitpim")

    assert False


def getresourcefiles(wildcard):
    "Returns a list of filenames matching the wildcard in the resource directory"
    l = glob.glob(os.path.join(resourcedirectory, wildcard))
    l.sort()
    return l


# Where to find bitmaps etc
resourcedirectory = os.path.join(common.get_main_dir(), 'resources')
helpdirectory = os.path.join(common.get_main_dir(), 'help')

# See strorunicode comment in common
if wx.USE_UNICODE:

    def strorunicode(s):
        if s is None: return s
        if isinstance(s, unicode): return s
        return str(s)

    common.strorunicode = strorunicode
    del strorunicode

else:
    if IsMSWindows():
        name="bitpim.chm"
    else:
        name="bitpim.htb"
    for p,mention in paths:
        if os.path.isfile(j(p, name)):
            if mention:
                print "Using help file from "+p
            return j(p, "bitpim")
    assert False
def getresourcefiles(wildcard):
    "Returns a list of filenames matching the wildcard in the resource directory"
    l=glob.glob(os.path.join(resourcedirectory, wildcard))
    l.sort()
    return l
resourcedirectory=os.path.join(common.get_main_dir(), 'resources')
helpdirectory=os.path.join(common.get_main_dir(), 'help')
if wx.USE_UNICODE:
    def strorunicode(s):
        if s is None: return s
        if isinstance(s, unicode): return s
        return str(s)
    common.strorunicode=strorunicode
    del strorunicode
else:
    def strorunicode(s):
        if s is None: return s
        try:
            return str(s)
        except UnicodeEncodeError:
            return s.encode("ascii", "replace")
"Routines to do various file format conversions"
import os
import tempfile
import struct
import sys
import wx
import common
class ConversionFailed(Exception): pass
helperdir=os.path.join(common.get_main_dir(), "helpers")
osext={'win32': '.exe',
       'darwin': '.mbin',
       'linux2': '.lbin'} \
       [sys.platform]
if sys.platform=='win32':
    import win32api
    def shortfilename(x):
        if " " in x:
            return win32api.GetShortPathName(x)
        return x
else:
    def shortfilename(x): return x
def gethelperbinary(basename):
    "Returns the full pathname to the specified helper binary"
    if basename=="pvconv":
        return getpvconvbinary()
    f=os.path.join(helperdir, basename)+osext
    try:
        f=shortfilename(f)
    except:
        raise common.HelperBinaryNotFound(basename, basename+osext, [helperdir])
    if not os.path.isfile(f):
示例#4
0
import contextlib
import os
import tempfile
import struct
import subprocess
import sys
import wx

import common


class ConversionFailed(Exception):
    pass


helperdir = os.path.join(common.get_main_dir(), "helpers")

osext={'win32': '.exe',
       'darwin': '.mbin',
       'linux2': '.lbin'} \
       [sys.platform]

# This shortname crap is needed because Windows programs (including ffmpeg)
# don't correctly parse command line arguments.
if sys.platform == 'win32':
    import win32api

    def shortfilename(x):
        # the name may already be short (eg from tempfile which always returns short names)
        # and may not exist, so we are careful to only call GetShortPathName if necessary
        if " " in x: