Exemplo n.º 1
0
def do_get_system_conf_dirs():
    #the system wide configuration directory
    try:
        from Foundation import NSSearchPathForDirectoriesInDomains, NSApplicationSupportDirectory, NSLocalDomainMask, NSSystemDomainMask  #@UnresolvedImport
        dirs = NSSearchPathForDirectoriesInDomains(
            NSApplicationSupportDirectory,
            NSLocalDomainMask | NSSystemDomainMask, False)
        return list(dirs)
    except:
        pass
    #fallback to hardcoded:
    default_conf_dir = "/Library/Application Support/Xpra"
    return [os.environ.get("XPRA_SYSCONF_DIR", default_conf_dir)]
Exemplo n.º 2
0
def do_get_default_log_dirs():
    dirs = []
    try:
        from Foundation import NSSearchPathForDirectoriesInDomains, NSLibraryDirectory, NSUserDomainMask  #@UnresolvedImport
        udirs = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
                                                    NSUserDomainMask, False)
        for x in udirs:
            #ie: ~/Library/
            dirs.append(os.path.join(x, "Logs", "Xpra"))
    except:
        dirs.append("~/Library/Logs/Xpra")
    dirs.append("/tmp")
    return dirs
Exemplo n.º 3
0
def do_get_download_dir():
    d = "~/Downloads"
    try:
        from Foundation import (
            NSSearchPathForDirectoriesInDomains, NSDownloadsDirectory, NSUserDomainMask,    #@UnresolvedImport
            )
        d = NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSUserDomainMask, False)[0]
        #(should be "~/Downloads")
    except Exception:
        pass
    if not os.path.exists(os.path.expanduser(d)):
        return "~"
    return d
Exemplo n.º 4
0
def do_get_user_conf_dirs():
    #the system wide configuration directory
    try:
        #when running sandboxed, it may look like this:
        #~/Library/Containers/<bundle_id>/Data/Library/Application Support/
        from Foundation import NSSearchPathForDirectoriesInDomains, NSApplicationSupportDirectory, NSUserDomainMask  #@UnresolvedImport
        dirs = list(
            NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,
                                                NSUserDomainMask, False))
    except:
        #fallback to hardcoded:
        dirs = ["/Library/Application Support/Xpra"]
    dirs.append("~/.xpra")
    return dirs
Exemplo n.º 5
0
 def directory(cls):
     if cls._cached_directory is None:
         if platform.system() == 'Darwin':
             from Foundation import NSApplicationSupportDirectory, NSSearchPathForDirectoriesInDomains, NSUserDomainMask
             cls._cached_directory = os.path.join(
                 NSSearchPathForDirectoriesInDomains(
                     NSApplicationSupportDirectory, NSUserDomainMask,
                     True)[0], 'Blink')
         elif platform.system() == 'Windows':
             cls._cached_directory = os.path.join(os.environ['APPDATA'],
                                                  'Blink')
         else:
             cls._cached_directory = Path('~/.blink').normalized
     return DirectoryContextManager(cls._cached_directory)
Exemplo n.º 6
0
def do_get_system_conf_dirs():
    #the system wide configuration directory
    dirs = []
    try:
        from Foundation import  NSSearchPathForDirectoriesInDomains, NSApplicationSupportDirectory, NSLocalDomainMask, NSSystemDomainMask  #@UnresolvedImport
        sdirs = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSLocalDomainMask|NSSystemDomainMask, False)
        for x in sdirs:
            #ie: "/Library/Application Support/Xpra"
            dirs.append(os.path.join(x, "Xpra"))
    except:
        #fallback to hardcoded:
        default_conf_dir = "/Library/Application Support/Xpra"
        dirs = [os.environ.get("XPRA_SYSCONF_DIR", default_conf_dir)]
    dirs.append("/etc/xpra")
    return dirs
Exemplo n.º 7
0
    def start(self):
        notification_center = NotificationCenter()
        settings = SIPSimpleSettings()

        download_folder = unicodedata.normalize(
            'NFC',
            NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory,
                                                NSUserDomainMask, True)[0])

        for name in self.filename_generator(
                os.path.join(download_folder, self.file_name)):
            if not os.path.exists(name) and not os.path.exists(name +
                                                               ".download"):
                self.file_path = name + '.download'
                break

        self.ft_info = FileTransferInfo(
            transfer_id=self.transfer_id,
            direction='incoming',
            local_uri=format_identity_to_string(self.account)
            if self.account is not BonjourAccount() else 'bonjour',
            file_size=self.file_size,
            remote_uri=self.remote_identity,
            file_path=self.file_path)

        BlinkLogger().log_info(u"Will write file to %s" % self.file_path)
        self.file_selector.fd = open(self.file_path, "w+")

        self.ft_info.status = "preparing"
        self.status = "Accepting File Transfer..."

        notification_center.add_observer(self, sender=self)
        notification_center.add_observer(self, sender=self.session)
        notification_center.add_observer(self, sender=self.stream)

        BlinkLogger().log_info("Initiating Incoming File Transfer")
        notification_center.post_notification(
            "BlinkFileTransferInitializing",
            self,
            data=TimestampedNotificationData())
        notification_center.post_notification(
            "BlinkFileTransferInitiated",
            self,
            data=TimestampedNotificationData())
    def revealFile_(self, sender):
        if self.transfer and self.transfer.ft_info and self.transfer.ft_info.file_path:
            path = self.transfer.ft_info.file_path
        elif self.oldTransferInfo:
            environ = NSProcessInfo.processInfo().environment()
            inSandbox = environ.objectForKey_("APP_SANDBOX_CONTAINER_ID")
            if inSandbox is not None:
                download_folder = unicodedata.normalize(
                    'NFC',
                    NSSearchPathForDirectoriesInDomains(
                        NSDownloadsDirectory, NSUserDomainMask, True)[0])
                NSWorkspace.sharedWorkspace().openFile_(download_folder)
                return
            path = self.oldTransferInfo.file_path
        else:
            return

        dirname = os.path.dirname(path)
        NSWorkspace.sharedWorkspace().selectFile_inFileViewerRootedAtPath_(
            path, dirname)
Exemplo n.º 9
0
def retrieve_account_identifiers():
    path = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
                                               NSUserDomainMask,
                                               True).firstObject()
    path = os.path.join(path, 'Group Containers',
                        'Q8B696Y8U4.com.ddeville.spillo', 'Library',
                        'Preferences', 'Q8B696Y8U4.com.ddeville.spillo.plist')

    data = NSData.dataWithContentsOfFile_(path)
    if data is None:
        return None

    defaults = NSPropertyListSerialization.propertyListWithData_options_format_error_(
        data, 0, None, None)[0]
    if defaults is None:
        return None

    accounts = defaults.get("accounts")
    if accounts is None:
        return None

    return accounts.valueForKey_("identifier")
Exemplo n.º 10
0
def application_support(name):
    """Return the application support folder path for the given `name`, creating it if it doesn't exist."""
    app_support_path = os.path.join(NSSearchPathForDirectoriesInDomains(14, 1, 1).objectAtIndex_(0), name)
    if not os.path.isdir(app_support_path):
        os.mkdir(app_support_path)
    return app_support_path
Exemplo n.º 11
0
    def start(self):
        notification_center = NotificationCenter()
        settings = SIPSimpleSettings()

        download_folder = unicodedata.normalize(
            'NFC',
            NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory,
                                                NSUserDomainMask, True)[0])
        for name in self.filename_generator(
                os.path.join(download_folder, self.file_name)):
            if not os.path.exists(name) and not os.path.exists(name +
                                                               ".download"):
                self.file_path = name + '.download'
                break

        BlinkLogger().log_info(u"File will be written to %s" % self.file_path)
        self.file_selector.fd = open(self.file_path, "w+")

        self.ft_info = FileTransferInfo(
            transfer_id=self.transfer_id,
            direction='incoming',
            local_uri=format_identity_to_string(self.account)
            if self.account is not BonjourAccount() else 'bonjour',
            file_size=self.file_size,
            remote_uri=self.remote_identity,
            file_path=self.file_path)

        BlinkLogger().log_info("Pull File Transfer Request started %s" %
                               self.file_path)

        self.stream = FileTransferStream(self.account, self.file_selector,
                                         'recvonly')
        self.session = Session(self.account)

        notification_center.add_observer(self, sender=self)
        notification_center.add_observer(self, sender=self.session)
        notification_center.add_observer(self, sender=self.stream)

        self.status = "Requesting File..."
        self.ft_info.status = "requesting"

        BlinkLogger().log_info(u"Initiating DNS Lookup of %s to %s" %
                               (self.account, self.target_uri))
        lookup = DNSLookup()
        notification_center.add_observer(self, sender=lookup)

        if isinstance(self.account,
                      Account) and self.account.sip.outbound_proxy is not None:
            uri = SIPURI(host=self.account.sip.outbound_proxy.host,
                         port=self.account.sip.outbound_proxy.port,
                         parameters={
                             'transport':
                             self.account.sip.outbound_proxy.transport
                         })
            BlinkLogger().log_info(
                u"Initiating DNS Lookup for SIP routes of %s (through proxy %s)"
                % (self.target_uri, uri))
        elif isinstance(self.account,
                        Account) and self.account.sip.always_use_my_proxy:
            uri = SIPURI(host=self.account.id.domain)
            BlinkLogger().log_info(
                u"Initiating DNS Lookup for SIP routes of %s (through account %s proxy)"
                % (self.target_uri, self.account.id))
        else:
            uri = self.target_uri
            BlinkLogger().log_info(
                u"Initiating DNS Lookup for SIP routes of %s" %
                self.target_uri)
        notification_center.post_notification(
            "BlinkFileTransferInitializing",
            self,
            data=TimestampedNotificationData())
        notification_center.post_notification(
            "BlinkFileTransferInitiated",
            self,
            data=TimestampedNotificationData())
        lookup.lookup_sip_proxy(uri, settings.sip.transport_list)
Exemplo n.º 12
0
 def directory(cls):
     if cls._cached_directory is None:
         application_name = str(NSBundle.mainBundle().infoDictionary().objectForKey_("CFBundleExecutable"))
         path = unicodedata.normalize('NFC', NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0])
         cls._cached_directory = os.path.join(path, application_name)
     return cls._cached_directory
Exemplo n.º 13
0
    def getLogDir(self):
        if platform == 'win32':
            # https://support.elitedangerous.com/kb/faq.php?id=108
            candidates = []

            # Steam and Steam libraries
            key = HKEY()
            if not RegOpenKeyEx(HKEY_CURRENT_USER, r'Software\Valve\Steam', 0,
                                KEY_READ, ctypes.byref(key)):
                valtype = DWORD()
                valsize = DWORD()
                if not RegQueryValueEx(
                        key, 'SteamPath', 0, ctypes.byref(valtype), None,
                        ctypes.byref(valsize)) and valtype.value == REG_SZ:
                    buf = ctypes.create_unicode_buffer(valsize.value / 2)
                    if not RegQueryValueEx(key, 'SteamPath', 0,
                                           ctypes.byref(valtype), buf,
                                           ctypes.byref(valsize)):
                        steampath = buf.value.replace(
                            '/', '\\')  # For some reason uses POSIX seperators
                        steamlibs = [steampath]
                        try:
                            # Simple-minded Valve VDF parser
                            with open(join(steampath, 'config', 'config.vdf'),
                                      'rU') as h:
                                for line in h:
                                    vals = line.split()
                                    if vals and vals[0].startswith(
                                            '"BaseInstallFolder_'):
                                        steamlibs.append(
                                            vals[1].strip('"').replace(
                                                '\\\\', '\\'))
                        except:
                            pass
                        for lib in steamlibs:
                            candidates.append(
                                join(lib, 'steamapps', 'common',
                                     'Elite Dangerous Horizons', 'Products'))
                            candidates.append(
                                join(lib, 'steamapps', 'common',
                                     'Elite Dangerous', 'Products'))
                RegCloseKey(key)

            # Next try custom installation under the Launcher
            candidates.append(self.getCustomLogDir() or '')

            # Standard non-Steam locations
            programs = ctypes.create_unicode_buffer(MAX_PATH)
            ctypes.windll.shell32.SHGetSpecialFolderPathW(
                0, programs, CSIDL_PROGRAM_FILESX86, 0)
            candidates.append(join(programs.value, 'Frontier', 'Products')),

            applocal = ctypes.create_unicode_buffer(MAX_PATH)
            ctypes.windll.shell32.SHGetSpecialFolderPathW(
                0, applocal, CSIDL_LOCAL_APPDATA, 0)
            candidates.append(
                join(applocal.value, 'Frontier_Developments', 'Products'))

            for game in ['elite-dangerous-64', 'FORC-FDEV-D-1'
                         ]:  # Look for Horizons in all candidate places first
                for base in candidates:
                    if isdir(base):
                        for d in listdir(base):
                            if d.startswith(game) and isfile(
                                    join(base, d, 'AppConfig.xml')) and isdir(
                                        join(base, d, 'Logs')):
                                return join(base, d, 'Logs')

        elif platform == 'darwin':
            # https://support.frontier.co.uk/kb/faq.php?id=97
            suffix = join("Frontier Developments", "Elite Dangerous", "Logs")
            paths = NSSearchPathForDirectoriesInDomains(
                NSApplicationSupportDirectory, NSUserDomainMask, True)
            if len(paths) and isdir(join(paths[0], suffix)):
                return join(paths[0], suffix)

        return None  # not found in standard places
Exemplo n.º 14
0
#from Foundation import *
#from CoreGraphics import *
from Quartz import CACurrentMediaTime, CATransaction
from pluginbase import PluginBase
import math
from Foundation import NSObject, NSLog, NSApplication
import sys
import traceback
import os
import re
sys.dont_write_bytecode = True

script_base = PluginBase(package='scriptplugins')
plugin_base = PluginBase(package='cocoasplitplugins')

library_dirs = NSSearchPathForDirectoriesInDomains(
    NSLibraryDirectory, NSAllDomainsMask - NSSystemDomainMask, True)

plugin_dirs = map(
    lambda x: x + "/Application Support/CocoaSplit/Plugins/Python",
    library_dirs)
plugin_dirs.append(NSBundle.mainBundle().builtInPlugInsPath() + "/Python")
plugin_source = plugin_base.make_plugin_source(searchpath=plugin_dirs)


def dummyCompletion():
    pass


def wait(duration=0):
    CSAnimationBlock.wait(duration)