talklib 1.2.4__tar.gz → 1.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: talklib
3
- Version: 1.2.4
3
+ Version: 1.3.0
4
4
  Summary: A package to automate processing of shows/segments airing on the TL
5
5
  Author-email: Ben Weddle <ben.weddle@gmail.com>
6
6
  Maintainer-email: Ben Weddle <ben.weddle@gmail.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "talklib"
3
- version = "1.2.4"
3
+ version = "1.3.0"
4
4
  description = "A package to automate processing of shows/segments airing on the TL"
5
5
  readme = "README.md"
6
6
  license = {file = "LICENSE.txt"}
@@ -0,0 +1,85 @@
1
+ '''
2
+ These are all of the environment variables we're calling from the PC.
3
+ They'll be imported into the other files in this package.
4
+
5
+ We're using the file so we have one central place from which
6
+ to reference them.
7
+
8
+ If you're installing the talklib module on a PC for the first time,
9
+ make sure all of these are declared in the PC's environment variables.
10
+
11
+ If you need to change them, you probably want to change them at the PC level, not here.
12
+
13
+ AUDIO DESTINATIONS:
14
+ variable name: destinations
15
+ variable value: a comma-separated list of destinations (network or local folders, etc),
16
+ for wherever you want the final, processed audio files to end up. You can put a space
17
+ after each comma, or not; either way will work.
18
+
19
+ EMAIL:
20
+ variable name: toEmail
21
+ variable value: a comma-separated list of email addresses where you want
22
+ notifications sent to. You can put a space after each comma,
23
+ or not; either way will work. You need at least one address; there is no
24
+ maximum number of addresses. You can ONLY send emails to nashville.gov
25
+ addresses. However, if you send an email to nashvilletalkinglibrary@nashville.gov,
26
+ that email will be forwarded to the TL Gmail account, which can then be
27
+ forwarded to any address. Metro ITS set up this relay server for us.
28
+
29
+ TWILIO
30
+ variable name: twilio_to
31
+ variable value: a comma-separated list of phone numbers you want alerts/notifications
32
+ sent to. This includes both SMS and phone calls. You can put a space after each comma,
33
+ or not; either way will work. You need at least one number; there is no maximum.
34
+ The numbers should be formatted like this: +1xxxxxxxxxx with no spaces. That is,
35
+ +1 followed by a ten-digit US phone number. An example variable value:
36
+ +16158625804, +16158625800, +16158501020
37
+ '''
38
+
39
+ import os
40
+
41
+ class EV:
42
+ def __init__(self):
43
+ self.destinations = sort_destinations() # where should output files go? MUST BE A LIST EVEN WITH ONLY ONE
44
+ self.syslog_host = os.environ["syslog_server"] # ip of syslog server (PC with syslog software)
45
+ self.fromEmail = os.environ['fromEmail'] # from where should emails appear to come?
46
+ self.toEmail = sort_to_email() # to where should emails be sent?
47
+ self.mail_server = os.environ["mail_server_external"] # IP of mail server (ITS set this up for us)
48
+ self.twilio_sid = os.environ['twilio_sid'] # locate by logging in to Twilio website
49
+ self.twilio_token = os.environ['twilio_token']# locate by logging in to Twilio website
50
+ self.twilio_from = os.environ['twilio_from'] # locate by logging in to Twilio website
51
+ self.twilio_to = sort_twilio_to() # to where should texts/calls be sent
52
+ self.icecast_user = os.environ['icecast_user'] # our icecast username
53
+ self.icecast_pass = os.environ['icecast_pass'] # our icecast password
54
+
55
+
56
+ def sort_destinations():
57
+ destinations = os.environ['destinations']
58
+ destinations = destinations.split(",")
59
+ destination_list = []
60
+ for destination in destinations:
61
+ destination = destination.split() #remove whitespace
62
+ # the split() above returns a list, so we need to interate through it, even though it's only one string
63
+ for dest in destination:
64
+ destination_list.append(dest)
65
+ return destination_list
66
+
67
+ def sort_to_email():
68
+ to_emails = os.environ['toEmail']
69
+ to_emails = to_emails.split(",")
70
+ to_email_list = []
71
+ for email in to_emails:
72
+ email = email.split()
73
+ for i in email:
74
+ to_email_list.append(i)
75
+ return to_email_list
76
+
77
+ def sort_twilio_to():
78
+ twilio_to_numbers = os.environ['twilio_to']
79
+ twilio_to_numbers = twilio_to_numbers.split(",")
80
+ twilio_to_list = []
81
+ for number in twilio_to_numbers:
82
+ number = number.split()
83
+ for num in number:
84
+ twilio_to_list.append(num)
85
+ return twilio_to_list
@@ -61,37 +61,40 @@ class Notify:
61
61
  '''send voice call via twilio'''
62
62
  if not (self.twilio_enable and self.enable_all):
63
63
  return
64
- client = Client(self.EV.twilio_sid, self.EV.twilio_token)
64
+ for number in self.EV.twilio_to:
65
+ client = Client(self.EV.twilio_sid, self.EV.twilio_token)
65
66
 
66
- call = client.calls.create(
67
- twiml=f'<Response><Say>{message}</Say></Response>',
68
- to=self.EV.twilio_to,
69
- from_=self.EV.twilio_from
70
- )
71
- call.sid
67
+ call = client.calls.create(
68
+ twiml=f'<Response><Say>{message}</Say></Response>',
69
+ to=number,
70
+ from_=self.EV.twilio_from
71
+ )
72
+ call.sid
72
73
 
73
74
  def send_sms(self, message: str) -> None:
74
75
  '''send sms via twilio. '''
75
76
  if not (self.twilio_enable and self.enable_all):
76
77
  return
77
- client = Client(self.EV.twilio_sid, self.EV.twilio_token)
78
- SMS = client.messages.create(
79
- body=message,
80
- from_=self.EV.twilio_from,
81
- to=self.EV.twilio_to
82
- )
83
- SMS.sid
78
+ for number in self.EV.twilio_to:
79
+ client = Client(self.EV.twilio_sid, self.EV.twilio_token)
80
+ SMS = client.messages.create(
81
+ body=message,
82
+ from_=self.EV.twilio_from,
83
+ to=number
84
+ )
85
+ SMS.sid
84
86
 
85
87
  def send_mail(self, message: str, subject: str) -> None:
86
88
  '''send email to TL gmail account via relay address'''
87
89
  if not (self.email_enable and self.enable_all):
88
90
  return
89
- format = EmailMessage()
90
- format.set_content(message)
91
- format['Subject'] = subject
92
- format['From'] = self.EV.fromEmail
93
- format['To'] = self.EV.toEmail
91
+ for email in self.EV.toEmail:
92
+ format = EmailMessage()
93
+ format.set_content(message)
94
+ format['Subject'] = subject
95
+ format['From'] = self.EV.fromEmail
96
+ format['To'] = email
94
97
 
95
- mail = smtplib.SMTP(host=self.EV.mail_server)
96
- mail.send_message(format)
97
- mail.quit()
98
+ mail = smtplib.SMTP(host=self.EV.mail_server)
99
+ mail.send_message(format)
100
+ mail.quit()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: talklib
3
- Version: 1.2.4
3
+ Version: 1.3.0
4
4
  Summary: A package to automate processing of shows/segments airing on the TL
5
5
  Author-email: Ben Weddle <ben.weddle@gmail.com>
6
6
  Maintainer-email: Ben Weddle <ben.weddle@gmail.com>
@@ -1,28 +0,0 @@
1
- '''
2
- These are all of the environment variables we're calling from the PC.
3
- They'll be imported into the other files in this package.
4
-
5
- We're using the file so we have one central place from which
6
- to reference them.
7
-
8
- If you're installing the talklib module on a PC for the first time,
9
- make sure all of these are declared in the PC's environment variables.
10
-
11
- If you need to change them, you probably want to change them at the PC level, not here.
12
- '''
13
-
14
- import os
15
-
16
- class EV:
17
- def __init__(self):
18
- self.destinations = [os.environ['OnAirPC'], os.environ['ProductionPC']]# where should output files go? MUST BE A LIST EVEN WITH ONLY ONE
19
- self.syslog_host = os.environ["syslog_server"] # ip of syslog server (PC with syslog software)
20
- self.fromEmail = os.environ['fromEmail'] # from where should emails appear to come?
21
- self.toEmail = os.environ['toEmail'] # to where should emails be sent?
22
- self.mail_server = os.environ["mail_server_external"] # IP of mail server (ITS set this up for us)
23
- self.twilio_sid = os.environ['twilio_sid'] # locate by logging in to Twilio website
24
- self.twilio_token = os.environ['twilio_token']# locate by logging in to Twilio website
25
- self.twilio_from = os.environ['twilio_from'] # locate by logging in to Twilio website
26
- self.twilio_to = os.environ['twilio_to'] # to where should texts/calls be sent
27
- self.icecast_user = os.environ['icecast_user'] # our icecast username
28
- self.icecast_pass = os.environ['icecast_pass'] # our icecast password
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes