-
Notifications
You must be signed in to change notification settings - Fork 14
/
floobits.py
50 lines (40 loc) · 1.24 KB
/
floobits.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# coding: utf-8
import sys
import optparse
from floo import emacs_handler
from floo.common import reactor
from floo.common import utils
from floo.common import shared as G
def cb(port):
print('Now listening on %s' % port)
sys.stdout.flush()
def main():
G.__VERSION__ = '0.11'
G.__PLUGIN_VERSION__ = None
parser = optparse.OptionParser(usage='%prog [options]')
parser.add_option("-p", "--port",
dest="port",
default=0,
help="The port to listen on. Useful for debugging.")
parser.add_option("--set-version",
dest="version")
options, args = parser.parse_args()
port = int(options.port)
G.__PLUGIN_VERSION__ = options.version
if not G.__PLUGIN_VERSION__:
print('--set-version is a required argument')
print('args: %s' % ' '.join(args))
sys.exit(1)
utils.reload_settings()
try:
utils.normalize_persistent_data()
except Exception:
pass
emacs = emacs_handler.EmacsHandler()
G.emacs = emacs
_, port = reactor.reactor.listen(emacs, port=port)
utils.set_timeout(cb, 100, port)
reactor.reactor.block()
if __name__ == '__main__':
main()