示例#1
0
    def open_file(self, fn):
        filename = filename_type_to_os_filename(fn)
        ws = NSWorkspace.sharedWorkspace()
        # Let's only open files that are of content type - we don't want to
        # automatically launch executables here.
        typ, error = ws.typeOfFile_error_(filename, None)
        if not typ or error:
            logging.warn('Cannot determine UTI of file %s' % fn)
            return

        if ws.type_conformsToType_(typ, 'public.executable'):
            logging.warn('Not opening executable file %s' % fn)
            return

        ok, externalApp, movieType = ws.getInfoForFile_application_type_(
            filename, None, None)
        if ok:
            if externalApp == bundle.getBundlePath():
                logging.warn('trying to play movie externally with ourselves.')
                ok = False
            else:
                ok = ws.openFile_withApplication_andDeactivate_(
                    filename, nil, YES)
        if not ok:
            logging.warn("movie %s could not be externally opened" % fn)
示例#2
0
文件: resources.py 项目: cool-RR/Miro
def theme_path(theme, relative_path):
    # XXX sigh.
    # Unicode kludge.  This wouldn't be a problem once we switch to Python 3.
    bundlePath = bundle.getBundlePath().encode('utf-8')
    if isinstance(theme, unicode):
        theme = theme.encode('utf-8')
    if isinstance(relative_path, unicode):
        relative_path = relative_path.encode('utf-8')
    path = os.path.join(bundlePath, "Contents", "Theme", theme,
            relative_path)
    return path
示例#3
0
def theme_path(theme, relative_path):
    # XXX sigh.
    # Unicode kludge.  This wouldn't be a problem once we switch to Python 3.
    bundlePath = bundle.getBundlePath().encode('utf-8')
    if isinstance(theme, unicode):
        theme = theme.encode('utf-8')
    if isinstance(relative_path, unicode):
        relative_path = relative_path.encode('utf-8')
    path = os.path.join(bundlePath, "Contents", "Theme", theme,
            relative_path)
    return path
示例#4
0
 def open_file(self, fn):
     filename = filename_type_to_os_filename(fn)
     ws = NSWorkspace.sharedWorkspace()
     ok, externalApp, movieType = ws.getInfoForFile_application_type_(filename, None, None)
     if ok:
         if externalApp == bundle.getBundlePath():
             logging.warn('trying to play movie externally with ourselves.')
             ok = False
         else:
             ok = ws.openFile_withApplication_andDeactivate_(filename, nil, YES)
     if not ok:
         logging.warn("movie %s could not be externally opened" % fn)
示例#5
0
def register_components():
    bundlePath = bundle.getBundlePath()
    componentsDirectoryPath = os.path.join(bundlePath, "Contents", "Components")
    components = glob.glob(os.path.join(componentsDirectoryPath, "*.component"))
    for component in components:
        cmpName = os.path.basename(component)
        stdloc1 = os.path.join(os.path.sep, "Library", "Quicktime", cmpName)
        stdloc2 = os.path.join(os.path.sep, "Library", "Audio", "Plug-Ins", "Components", cmpName)
        if not os.path.exists(stdloc1) and not os.path.exists(stdloc2):
            ok = qtcomp.register(component.encode("utf-8"))
            if ok:
                logging.debug("Successfully registered embedded component: %s", cmpName)
            else:
                logging.warn("Error while registering embedded component: %s", cmpName)
        else:
            logging.debug("Skipping embedded %s registration, " "already installed.", cmpName)
示例#6
0
def register_components():
    bundlePath = bundle.getBundlePath()
    componentsDirectoryPath = os.path.join(bundlePath, 'Contents',
                                           'Components')
    components = glob.glob(os.path.join(componentsDirectoryPath,
                                        '*.component'))
    for component in components:
        cmpName = os.path.basename(component)
        stdloc1 = os.path.join(os.path.sep, "Library", "Quicktime", cmpName)
        stdloc2 = os.path.join(os.path.sep, "Library", "Audio", "Plug-Ins",
                               "Components", cmpName)
        if not os.path.exists(stdloc1) and not os.path.exists(stdloc2):
            ok = qtcomp.register(component.encode('utf-8'))
            if ok:
                logging.debug('Successfully registered embedded component: %s',
                              cmpName)
            else:
                logging.warn('Error while registering embedded component: %s',
                             cmpName)
        else:
            logging.debug(
                'Skipping embedded %s registration, '
                'already installed.', cmpName)
示例#7
0
    def open_file(self, fn):
        filename = filename_type_to_os_filename(fn)
        ws = NSWorkspace.sharedWorkspace()
        # Let's only open files that are of content type - we don't want to
        # automatically launch executables here.
        typ, error = ws.typeOfFile_error_(filename, None)
        if not typ or error:
            logging.warn('Cannot determine UTI of file %s' % fn)
            return

        if ws.type_conformsToType_(typ, 'public.executable'):
            logging.warn('Not opening executable file %s' % fn)
            return

        ok, externalApp, movieType = ws.getInfoForFile_application_type_(filename, None, None)
        if ok:
            if externalApp == bundle.getBundlePath():
                logging.warn('trying to play movie externally with ourselves.')
                ok = False
            else:
                ok = ws.openFile_withApplication_andDeactivate_(filename, nil, YES)
        if not ok:
            logging.warn("movie %s could not be externally opened" % fn)