コード例 #1
0
ファイル: attachment.py プロジェクト: HieronymusCH/TaskCoach
    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))
コード例 #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
コード例 #3
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
コード例 #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
コード例 #5
0
ファイル: DesktopTest.py プロジェクト: HieronymusCH/TaskCoach
    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
コード例 #6
0
ファイル: DesktopTest.py プロジェクト: dfraser74/taskcoach
    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
コード例 #7
0
ファイル: __init__.py プロジェクト: HieronymusCH/TaskCoach
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)
コード例 #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)
コード例 #9
0
ファイル: __init__.py プロジェクト: HieronymusCH/TaskCoach
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)))
コード例 #10
0
ファイル: attachment.py プロジェクト: HieronymusCH/TaskCoach
 def open(self, workingDir=None):
     return desktop.open(self.location())
コード例 #11
0
ファイル: attachment.py プロジェクト: dfraser74/taskcoach
 def open(self, workingDir=None):
     return desktop.open(self.location())
コード例 #12
0
ファイル: attachment.py プロジェクト: HieronymusCH/TaskCoach
 def open(self, workingDir=None):
     desktop.open(self.uri)