Check-in [5a6185c3aa]
Overview
Comment: | Use subprocess.list2cmdline() for Windows, and pipes.quote() for BSD/Linux command execution. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
5a6185c3aa1648d1ee5c64ae3dfd7d02 |
User & Date: | mario on 2016-11-06 14:41:39 |
Other Links: | manifest | tags |
Context
2016-11-06
| ||
18:51 | Add unichr() function alias for Python3. check-in: 049c5a6edd user: mario tags: trunk | |
14:41 | Use subprocess.list2cmdline() for Windows, and pipes.quote() for BSD/Linux command execution. check-in: 5a6185c3aa user: mario tags: trunk | |
12:45 | Make action.cmd() more explicit again. Introduce cmd= override flag for action.run_fmt_url(). So that specbuttons can use it instead of just interpol(). Thus the urn:/mime handlers will engage as well. check-in: 2b300a090d user: mario tags: trunk | |
Changes
Modified action.py from [53a5386135] to [8587c265d6].
1 2 3 4 5 6 | # encoding: UTF-8 # api: streamtuner2 # type: functions # category: io # title: play/record actions # description: Starts audio applications, guesses MIME types for URLs | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # encoding: UTF-8 # api: streamtuner2 # type: functions # category: io # title: play/record actions # description: Starts audio applications, guesses MIME types for URLs # version: 1.2.0 # priority: core # # Multimedia interface for starting audio players, recording app, # or web browser (listed as "url/http" association in players). # It maps audio MIME types, and extracts/converts playlist types # (PLS, M3U, XSPF, SMIL, JSPF, ASX, raw urls). # |
︙ | ︙ | |||
33 34 35 36 37 38 39 40 41 42 43 44 45 46 | import re import os import platform import copy import json from datetime import datetime from xml.sax.saxutils import escape as xmlentities, unescape as xmlunescape import ahttp from config import * | > | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import re import os import platform import copy import json import subprocess, pipes from datetime import datetime from xml.sax.saxutils import escape as xmlentities, unescape as xmlunescape import ahttp from config import * |
︙ | ︙ | |||
128 129 130 131 132 133 134 | # "urn:reciva": stream_resolve(), } # Exec wrapper def run(cmd): | > > | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | # "urn:reciva": stream_resolve(), } # Exec wrapper def run(cmd): if "exec" in conf: cmd = conf.cmd % cmd elif conf.windows: cmd = "start " + cmd else: cmd = cmd + " &" try: log.EXEC(cmd) os.system(cmd) except: |
︙ | ︙ | |||
175 176 177 178 179 180 181 | def record(row={}, audioformat="audio/mpeg", source="href", append=None): run_fmt_url(row, audioformat, source, conf.record, append=append) # OS shell command escaping # def quote(ins): | > > > | > | > < | < < | | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | def record(row={}, audioformat="audio/mpeg", source="href", append=None): run_fmt_url(row, audioformat, source, conf.record, append=append) # OS shell command escaping # def quote(ins): if type(ins) is list: return " ".join([quote(s) for s in ins]) # Windows: double quotes elif conf.windows: return subprocess.list2cmdline([ins]) return '"%s"' % ins # Posix-style shell quoting else: return pipes.quote(ins) return "%r" % ins # Convert e.g. "text/x-scpls" MIME types to just "pls" monikers # def listfmt(t = "pls"): return listfmt_t.get(t, t) # e.g. "pls" or still "text/x-unknown" |
︙ | ︙ |