Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #101564

Re: use Python and an outlook: protocol URL to bring up a specific email

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: use Python and an outlook: protocol URL to bring up a specific email
Date Wed, 13 Jan 2016 04:52:39 +1100
Lines 29
Message-ID <mailman.79.1452621162.13488.python-list@python.org> (permalink)
References <ab47c98f-69af-49ee-b1c4-bced0c48a001@googlegroups.com> <CAPTjJmpjk+LVUmV9orqvVVmbWNXzsBYKO+be3A8P62znZZF5kQ@mail.gmail.com> <CACL+1auQXdkXyV0J22nKpOxt0ZLEGdkvHzxc-Mp2MfiJXsW_ug@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de lFsiX2GOMflvb+N4a2dE1A24bZ7wv/tbKI/FdDtvoGeg==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'subject:Python': 0.05; 'cc:addr:python-list': 0.09; '"%s"\'': 0.09; 'command.': 0.09; 'title.': 0.09; 'jan': 0.11; 'wed,': 0.15; 'argument': 0.15; 'properly': 0.15; '2016': 0.16; '3:51': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'fwiw': 0.16; 'popping': 0.16; 'quoted': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:URL': 0.16; 'wrote:': 0.16; ';-)': 0.18; 'shell': 0.18; '>>>': 0.20; 'windows': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'arguments': 0.22; 'simpler': 0.22; 'am,': 0.23; 'tried': 0.24; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'command': 0.26; 'chris': 0.26; 'equivalent': 0.27; 'used,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'said,': 0.27; 'correct': 0.28; 'went': 0.28; '13,': 0.29; 'escaped': 0.29; 'invoke': 0.29; 'protocol.': 0.29; 'referenced': 0.29; 'work.': 0.30; 'code': 0.30; 'strongly': 0.30; 'window': 0.30; 'skip:s 30': 0.31; 'though,': 0.32; 'doubt': 0.33; 'tue,': 0.34; 'handle': 0.34; 'received:google.com': 0.35; 'clear': 0.35; 'subject:use': 0.35; 'but': 0.36; 'should': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'being': 0.37; '12,': 0.37; 'received:209': 0.38; 'some': 0.40; 'secure': 0.60; 'more': 0.63; 'alternative.': 0.84; 'chrisa': 0.84; 'pasting': 0.84; 'to:none': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=En1H0kzSSKIaO29gpHXLy8NZqAVtfRLKTsrpsNK2y9Y=; b=vXW2HWw9TtAXm2FsNFSQ46vFgKTuaKBa2035EXFi/bAT6GVffdjOmMW72alNLBOISK dD6aAWScFo1f/P10xFyJnUyz09jwABN8b5ESLMk03Nu53uizbUnODpES/q2ZRE0rx2Pe QgKQGlsWwU37aIqYTADTd5pUv2NMpDvQJbRjNlQoFcPYXbz5QqGDIrxpfKletaBZdCG8 K3KOczBhTc8o/C25gYaey8CprS4QzLeQQPhrHMw2HxXz0iusqe1Og8Qp6sHxRhpexCtx BstpTsDT66B7DHlDvzKP+jpsGAa4mFMUcnvyCHOydvDAZxOoJWgK/AKAvHvOin4FE3x4 zfRw==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc:content-type; bh=En1H0kzSSKIaO29gpHXLy8NZqAVtfRLKTsrpsNK2y9Y=; b=X+cvAM7zNSR4JPSlcYPwUnIesEapO8BHXWYPpdzPRSp44iYv1Agieiz4K1KKpGr9zk vo7rnuAvVtWbxIZ7bwOJ/N7on7t0A4CqcnzDdgAdczV/7BVcqQjCIrbmrabLGbbnJMRc athMC1HwDKGy2CkHK64uXFWoYtbtOEBMlxEOUgzvJndYCVNYklAkzwnu5JHg0DN66+um NzKfhbGU1F8IDC1PWn+N9hdBb/tgjTF4YdWvXOZoF2DwRtKwlw01z3twDRGl++cwdwDR Ok3rtjWm1pxeU5ju0H6Rqmo1sZYXxccYv1aH4XeLkC5aDA4usTbPmoxy9ettCHBGh8Bf 0LwA==
X-Gm-Message-State ALoCoQkwcJCfX2zQj4YfqFGfU6TimdHIJV1cvyWlOiNRw3z0G92NwXD5AsHBbMYjuT4GHwaatHRMO2HJkcECa7XYvq1NdGN+Lg==
X-Received by 10.107.47.162 with SMTP id v34mr69885478iov.19.1452621159946; Tue, 12 Jan 2016 09:52:39 -0800 (PST)
In-Reply-To <CACL+1auQXdkXyV0J22nKpOxt0ZLEGdkvHzxc-Mp2MfiJXsW_ug@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:101564

Show key headers only | View raw


On Wed, Jan 13, 2016 at 4:37 AM, eryk sun <eryksun@gmail.com> wrote:
> On Tue, Jan 12, 2016 at 11:10 AM, Chris Angelico <rosuav@gmail.com> wrote:
>> On Wed, Jan 13, 2016 at 3:51 AM, jkn <jkn_gg@nicorp.f9.co.uk> wrote:
>>> I happy to carve some code without using urllib, but I am not clear what I
>>> actually need to do to 'open' such a URL using this protocol. FWIW I can paste
>>> this URL into Windows Explorer and I get the referenced email popping up ;-)
>>
>> What happens if you invoke the 'start' command using subprocess?
>>
>> subprocess.check_call(["start", url])
>>
>> In theory, that should be equivalent to pasting it into Explorer. In theory.
>
> start is a shell command. It also has a quirk that the first quoted
> argument is the window title. Here's the correct call:
>
>     subprocess.check_call('start "title" "%s"' % url, shell=True)

Is that properly escaped to handle any arbitrary URL? I doubt it.

Do you actually need shell=True? I would strongly recommend using the
form that I used, unless it can be proven that that doesn't work.

> That said, since no arguments are being passed the simpler and more
> secure way to call ShellExecute in this case is os.startfile(url).

Yes. The OP mentioned having tried this, though, so I went for an alternative.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

use Python and an outlook: protocol URL to bring up a specific email jkn <jkn_gg@nicorp.f9.co.uk> - 2016-01-12 08:51 -0800
  Re: use Python and an outlook: protocol URL to bring up a specific email Chris Angelico <rosuav@gmail.com> - 2016-01-13 04:10 +1100
    Re: use Python and an outlook: protocol URL to bring up a specific email jkn <jkn_gg@nicorp.f9.co.uk> - 2016-01-12 09:22 -0800
  Re: use Python and an outlook: protocol URL to bring up a specific email eryk sun <eryksun@gmail.com> - 2016-01-12 11:37 -0600
  Re: use Python and an outlook: protocol URL to bring up a specific email Chris Angelico <rosuav@gmail.com> - 2016-01-13 04:52 +1100
    Re: use Python and an outlook: protocol URL to bring up a specific email Christian Gollwitzer <auriocus@gmx.de> - 2016-01-12 19:04 +0100
  Re: use Python and an outlook: protocol URL to bring up a specific email eryk sun <eryksun@gmail.com> - 2016-01-12 13:12 -0600

csiph-web