Exemple #1
0
    def open(self, workingDir=None):
        if workingDir is not None and not os.path.isabs(self.filename):
            path = os.path.join(workingDir, self.filename)
        else:
            path = self.filename

        desktop.open(os.path.normpath(path))
Exemple #2
0
def openFile(filename):
    try:
        desktop.open(filename)
    except OSError:
        if platform.system() == 'Linux':
            if os.system('xdg-open "%s"' % filename):
                raise OSError('Unable to open "%s"')
        else:
            raise
def openFile(filename):
    try:
        desktop.open(filename)
    except OSError:
        if platform.system() == 'Linux':
            if os.system('xdg-open "%s"' % filename):
                raise OSError('Unable to open "%s"')
        else:
            raise
Exemple #4
0
    def testOpenByForcingAnException(self):
        """ desktop.open will open a browser or other program and we
            don't want that during unit testing. So we provide a non-existing
            desktop, which will cause desktop.open to raise an exception. """

        try:
            desktop.open("http://www.taskcoach.org", desktop="Force exception")
            self.fail("desktop.open() ignored " "our non-existing desktop?!")  # pragma: no cover
        except OSError:
            pass
    def testOpenByForcingAnException(self):
        ''' desktop.open will open a browser or other program and we
        don't want that during unittesting. So we provide a non-existing
        desktop, which will cause desktop.open to raise an exception. '''

        try:
            desktop.open('http://taskcoach.niessink.com',
                desktop='Force exception')
            self.fail('desktop.open ignored our non-existing desktop?!')
        except OSError:
            pass
Exemple #6
0
    def testOpenByForcingAnException(self):
        ''' desktop.open will open a browser or other program and we
            don't want that during unit testing. So we provide a non-existing
            desktop, which will cause desktop.open to raise an exception. '''

        try:
            desktop.open('http://www.taskcoach.org', desktop='Force exception')
            self.fail('desktop.open() ignored '
                      'our non-existing desktop?!')  # pragma: no cover
        except OSError:
            pass
Exemple #7
0
def openMail(filename):
    if os.name == 'nt':
        # Find out if Outlook is the so-called 'default' mailer.
        import _winreg
        key = _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT,
                              r'mailto\shell\open\command')
        try:
            value, type_ = _winreg.QueryValueEx(key, '')
            if type_ in [_winreg.REG_SZ, _winreg.REG_EXPAND_SZ]:
                if 'outlook.exe' in value.lower():
                    try:
                        if openMailWithOutlook(filename):
                            return
                    except:
                        pass
        finally:
            _winreg.CloseKey(key)

    desktop.open(filename)
Exemple #8
0
def openMail(filename):
    if os.name == 'nt':
        # Find out if Outlook is the so-called 'default' mailer.
        import _winreg
        key = _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT,
                              r'mailto\shell\open\command')
        try:
            value, type_ = _winreg.QueryValueEx(key, '')
            if type_ in [_winreg.REG_SZ, _winreg.REG_EXPAND_SZ]:
                if 'outlook.exe' in value.lower():
                    try:
                        if openMailWithOutlook(filename):
                            return
                    except:
                        pass
        finally:
            _winreg.CloseKey(key)

    desktop.open(filename)
Exemple #9
0
def writeMail(to, subject, body):
    def unicode_quote(s):
        # This is like urllib.quote but leaves out Unicode characters,
        # which urllib.quote does not support.
        chars = []
        for c in s:
            if ord(c) >= 128:
                chars.append(c)
            else:
                chars.append(urllib.quote(c))
        return ''.join(chars)

    # FIXME: Very  strange things happen on  MacOS X. If  there is one
    # non-ASCII character in the body, it works. If there is more than
    # one, it fails.  Maybe we should use Mail.app  directly ? What if
    # the user uses something else ?

    desktop.open(u'mailto:%s?subject=%s&body=%s' % (to,
                                                    unicode_quote(subject),
                                                    unicode_quote(body)))
Exemple #10
0
 def open(self, workingDir=None):
     return desktop.open(self.location())
Exemple #11
0
 def open(self, workingDir=None):
     return desktop.open(self.location())
Exemple #12
0
 def open(self, workingDir=None):
     desktop.open(self.uri)