Mercurial > code > home > repos > light9
annotate bin/vidref @ 964:ced2c5e5fb31
curvecalc can finally change songs without restarting, and it can optionally track the song from ascoltami (beware of losing curve edits in this mode!)
Ignore-this: 3a5349b015605c3a8d640d30ea255000
author | drewp@bigasterisk.com |
---|---|
date | Sat, 15 Jun 2013 08:21:33 +0000 |
parents | 1d9547f90737 |
children | b281ee32c785 |
rev | line source |
---|---|
729
b5efddd80dad
update more shbang lines
Drew Perttula <drewp@bigasterisk.com>
parents:
647
diff
changeset
|
1 #!bin/python |
882 | 2 from run_local import log |
935 | 3 from twisted.internet import gtk2reactor |
4 gtk2reactor.install() | |
941
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
5 from twisted.internet import reactor, defer |
525 | 6 import gobject |
7 gobject.threads_init() | |
522 | 8 import gtk |
941
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
9 import sys, logging, optparse, json |
523
9f36a105adb3
fix vidref to allow playback from webcam
drewp@bigasterisk.com
parents:
522
diff
changeset
|
10 sys.path.append(".") |
941
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
11 from light9 import networking |
937 | 12 from light9.vidref.main import Gui |
941
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
13 from light9.vidref.replay import snapshotDir |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
14 import cyclone.web, cyclone.httpclient, cyclone.websocket |
522 | 15 |
542
cfd5d5be1b50
vidref complete panels on each replay. replays load and delete pretty well
drewp@bigasterisk.com
parents:
541
diff
changeset
|
16 # find replay dirs correctly. show multiple |
cfd5d5be1b50
vidref complete panels on each replay. replays load and delete pretty well
drewp@bigasterisk.com
parents:
541
diff
changeset
|
17 # replays. trash. reorder/pin. dump takes that are too short; they're |
cfd5d5be1b50
vidref complete panels on each replay. replays load and delete pretty well
drewp@bigasterisk.com
parents:
541
diff
changeset
|
18 # just from seeking |
cfd5d5be1b50
vidref complete panels on each replay. replays load and delete pretty well
drewp@bigasterisk.com
parents:
541
diff
changeset
|
19 |
cfd5d5be1b50
vidref complete panels on each replay. replays load and delete pretty well
drewp@bigasterisk.com
parents:
541
diff
changeset
|
20 parser = optparse.OptionParser() |
cfd5d5be1b50
vidref complete panels on each replay. replays load and delete pretty well
drewp@bigasterisk.com
parents:
541
diff
changeset
|
21 parser.add_option("-v", "--verbose", action="store_true", |
cfd5d5be1b50
vidref complete panels on each replay. replays load and delete pretty well
drewp@bigasterisk.com
parents:
541
diff
changeset
|
22 help="logging.DEBUG") |
cfd5d5be1b50
vidref complete panels on each replay. replays load and delete pretty well
drewp@bigasterisk.com
parents:
541
diff
changeset
|
23 (options, args) = parser.parse_args() |
cfd5d5be1b50
vidref complete panels on each replay. replays load and delete pretty well
drewp@bigasterisk.com
parents:
541
diff
changeset
|
24 |
522 | 25 |
647
a30550d5827f
vidref shows more logs in the gui
Drew Perttula <drewp@bigasterisk.com>
parents:
542
diff
changeset
|
26 log.setLevel(logging.DEBUG) |
a30550d5827f
vidref shows more logs in the gui
Drew Perttula <drewp@bigasterisk.com>
parents:
542
diff
changeset
|
27 # limit the stdout one, but leave debug messages for the gtk logger |
a30550d5827f
vidref shows more logs in the gui
Drew Perttula <drewp@bigasterisk.com>
parents:
542
diff
changeset
|
28 log.handlers[0].setLevel(logging.DEBUG if options.verbose else logging.WARN) |
534
6f1eb6437c96
vidref refactor, start to add more widgets
drewp@bigasterisk.com
parents:
525
diff
changeset
|
29 logging.getLogger("restkit.client").setLevel(logging.WARN) |
6f1eb6437c96
vidref refactor, start to add more widgets
drewp@bigasterisk.com
parents:
525
diff
changeset
|
30 |
6f1eb6437c96
vidref refactor, start to add more widgets
drewp@bigasterisk.com
parents:
525
diff
changeset
|
31 |
941
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
32 class Snapshot(cyclone.web.RequestHandler): |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
33 @defer.inlineCallbacks |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
34 def post(self): |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
35 # save next pic |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
36 # return /snapshot/path |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
37 try: |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
38 outputFilename = yield self.settings.gui.snapshot() |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
39 |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
40 assert outputFilename.startswith(snapshotDir()) |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
41 out = networking.vidref.path( |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
42 "snapshot/%s" % outputFilename[len(snapshotDir()):].lstrip('/')) |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
43 |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
44 self.write(json.dumps({'snapshot': out})) |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
45 self.set_header("Location", out) |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
46 self.set_status(303) |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
47 except Exception as e: |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
48 import traceback |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
49 traceback.print_exc() |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
50 raise |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
51 |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
52 class SnapshotPic(cyclone.web.StaticFileHandler): |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
53 pass |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
54 |
937 | 55 |
941
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
56 gui = Gui() |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
57 |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
58 port = networking.vidref.port |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
59 reactor.listenTCP(port, cyclone.web.Application(handlers=[ |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
60 (r'/snapshot', Snapshot), |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
61 (r'/snapshot/(.*)', SnapshotPic, {"path": snapshotDir()}), |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
62 ], debug=True, gui=gui)) |
1d9547f90737
vidref can take snapshots and serve them back
drewp@bigasterisk.com
parents:
937
diff
changeset
|
63 log.info("serving on %s" % port) |
937 | 64 |
935 | 65 reactor.run() |
522 | 66 |