This repository was archived by the owner on Jan 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
61 lines (44 loc) · 1.34 KB
/
run.py
File metadata and controls
61 lines (44 loc) · 1.34 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
Entry point for program.
Author: Jack Romo <sharrackor@gmail.com>
"""
import sys, os
from dogegen import *
def main(args):
"""
Given command line arguments, generate a Doge meme or start a server / Unix service.
NB: The 'service' option is used internally by the dogegenservice script.
Args:
args (list[str]): List of command line arguments.
"""
if args[1] == "--server-start":
start_server(args)
elif args[1] == "--service-start":
start_service(args)
else:
make_meme_no_server(args)
def start_service(args):
"""
Given command line arguments, start a server as a Unix service.
Args:
args (list[str]): List of command line arguments.
"""
with open("/var/run/dogegenservice.pid", 'w') as pid_file:
pid_file.write(str(os.getpid()))
start_server(args)
def start_server(args):
"""
Given command line arguments, start a server.
Args:
args (list[str]): List of command line arguments.
"""
DogeServer.run_server(args[2], args[3], int(args[4]))
def make_meme_no_server(args):
"""
Given command line arguments, generate a Doge meme.
Args:
args (list[str]): List of command line arguments.
"""
DogeGen(args[3]).make_meme(args[1], args[2], int(args[4]))
if __name__ == "__main__":
main(sys.argv)