-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathct.py
More file actions
executable file
·41 lines (34 loc) · 1.19 KB
/
ct.py
File metadata and controls
executable file
·41 lines (34 loc) · 1.19 KB
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
#!/usr/bin/python
#
"""This small script will try to start/stop the daemon
Based upon whether the daemon is already running."""
import os
from optparse import OptionParser
import ctwww
pid_fn = os.path.join(os.path.expanduser('~'),'.cryptweet-webserver-pid')
options = None
arguments = None
def parse_options():
""" Parse all of the command line options, return them as a tuple (options, arguments)"""
# First thing, parse the command-line options, if any.
usage = "usage: %prog [options]"
parser = OptionParser(usage=usage)
parser.add_option("-p", "--port", dest="portnum", help="port number (default is port 8080)")
parser.add_option("-n", "--name", dest="hostname", help="hostname (default is localhost)")
(o,a) = parser.parse_args()
return (o,a)
def doit():
"""All the work is done here.
Check to see if the daemon is running.
If it is not running, start it.
If it is running, stop it."""
if os.path.isfile(pid_fn): # pid exists, we're running
ctwww.stop_it()
print 'CrypTweet webserver stopped.'
else:
global options, arguments
print 'CrypTweet webserver starting...'
ctwww.start_it(options, arguments)
if __name__ == '__main__':
(options, arguments) = parse_options()
doit()