-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmdify.py
executable file
·65 lines (51 loc) · 1.2 KB
/
cmdify.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/python
#
# Cmdify
#
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Imports #
from subprocess import call
#
# Public: Cmdify will take a single argument as input and create a
# customizable Growl notification via the `growlnotify`
#
class Cmdify:
#
# Public: Should be used to set configurable application constants
#
def __init__(self):
pass
#
# TODO: Define this for real (just using sample alert for now)
#
def parse_args(self, argv):
result = {}
result["message"]= "Sample Alert"
return result
def create_arg_string(self, arg_dict):
# Instantiate the args string
args = ""
# Add the message
args += "--message='"
args += arg_dict["message"]
args += "' "
return args
#
# Public: Simply broadcasts a given message via growlnotify
#
def broadcast(self, argv):
# Build the argument vector
arguments = self.parse_args(argv)
# Convert to a flat string
argument_str = self.create_arg_string(arguments)
# Notify
self.notify(argument_str)
return True
#
#
#
def notify(self, args):
# TODO: Throw a custom exception when `growlnotify` can't be found
call(["growlnotify", args])
return True