talklib 3.2.2__tar.gz → 3.2.3__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.4
2
2
  Name: talklib
3
- Version: 3.2.2
3
+ Version: 3.2.3
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 = "3.2.2"
3
+ version = "3.2.3"
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"}
@@ -41,21 +41,27 @@ import os
41
41
  class EV:
42
42
  def __init__(self):
43
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
44
+ self.syslog_host = get_EV(ev="syslog_server") # ip of syslog server (PC with syslog software)
45
+ self.fromEmail = get_EV(ev="fromEmail") # from where should emails appear to come?
46
+ self.toEmail = sort_to_email() # to where should emails be sent?
47
+ self.mail_server = get_EV(ev="mail_server_external") # IP of mail server (ITS set this up for us)
48
+ self.twilio_sid = get_EV(ev="twilio_sid") # locate by logging in to Twilio website
49
+ self.twilio_token = get_EV(ev="twilio_token") # locate by logging in to Twilio website
50
+ self.twilio_from = get_EV(ev="twilio_from") # locate by logging in to Twilio website
51
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
- self.pod_server_uname = os.environ['pod_server_uname']
52
+ self.icecast_user = get_EV(ev="icecast_user") # our icecast username
53
+ self.icecast_pass = get_EV(ev="icecast_pass") # our icecast password
54
+ self.pod_server_uname = get_EV(ev="pod_server_uname")
55
55
 
56
+ def get_EV(ev: str):
57
+ try:
58
+ ev = os.environ[ev]
59
+ return ev
60
+ except KeyError:
61
+ raise RuntimeError(f"Missing required environment variable: {ev}")
56
62
 
57
63
  def sort_destinations():
58
- destinations = os.environ['destinations']
64
+ destinations = get_EV(ev="destinations")
59
65
  destinations = destinations.split(",")
60
66
  destination_list = []
61
67
  for destination in destinations:
@@ -66,7 +72,7 @@ def sort_destinations():
66
72
  return destination_list
67
73
 
68
74
  def sort_to_email():
69
- to_emails = os.environ['toEmail']
75
+ to_emails = get_EV(ev="toEmail")
70
76
  to_emails = to_emails.split(",")
71
77
  to_email_list = []
72
78
  for email in to_emails:
@@ -76,7 +82,7 @@ def sort_to_email():
76
82
  return to_email_list
77
83
 
78
84
  def sort_twilio_to():
79
- twilio_to_numbers = os.environ['twilio_to']
85
+ twilio_to_numbers = get_EV(ev="twilio_to")
80
86
  twilio_to_numbers = twilio_to_numbers.split(",")
81
87
  twilio_to_list = []
82
88
  for number in twilio_to_numbers:
@@ -52,6 +52,7 @@ class SSH(BaseModel):
52
52
  user: str = EV().pod_server_uname
53
53
  connection: Type[Connection] = Connection(host=server, user=user)
54
54
  notifications: Notifications = Notifications()
55
+ folder_exists: ClassVar[str] = False
55
56
 
56
57
  def upload_file(self, file: str, folder: str) -> None:
57
58
  self.check_folder_exists(folder=folder)
@@ -139,10 +140,13 @@ The error from the SSH library is: {e}"
139
140
  self.upload_file(file="feed.xml", folder=folder)
140
141
 
141
142
  def check_folder_exists(self, folder: str) -> bool:
143
+ if SSH.folder_exists:
144
+ return True
142
145
  self.notifications.prep_syslog(message=f"checking if {folder}/ exists on server...")
143
146
  folders = self.get_folders()
144
147
  if folder.lower() in folders:
145
148
  self.notifications.prep_syslog(message=f"{folder}/ exists on server!")
149
+ SSH.folder_exists = True
146
150
  return True
147
151
 
148
152
  to_send = f"cannot find folder titled: {folder}/ on server"
@@ -175,6 +179,12 @@ class Episode(BaseModel):
175
179
  self.notifications.prep_syslog(message=f"pubDate will be: {pub_date}")
176
180
  return pub_date
177
181
 
182
+ def copyright(self) -> str:
183
+ year: int = datetime.now().year
184
+ copyright: str = f"© 1975-{year} Nashville Talking Library - Do not copy or redistribute"
185
+ self.notifications.prep_syslog(message=f"copyright will be: {copyright}")
186
+ return copyright
187
+
178
188
  def size_in_bytes(self, filename) -> str:
179
189
  size_in_bytes = os.path.getsize(filename)
180
190
  size_in_bytes = str(size_in_bytes)
@@ -298,6 +308,9 @@ class Episode(BaseModel):
298
308
  last_build_date = root.find('lastBuildDate')
299
309
  last_build_date.text = self.pub_date() # fine to use this same pub date, as the format for both is the same
300
310
 
311
+ copyright = root.find("copyright")
312
+ copyright.text = self.copyright()
313
+
301
314
  ET.indent(feed) # makes the XML pretty looking
302
315
  self.notifications.prep_syslog(message=f"writing feed file...")
303
316
  feed.write(self.feed_file, encoding="utf-8", xml_declaration=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: talklib
3
- Version: 3.2.2
3
+ Version: 3.2.3
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>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes