Merge branch 'master' of dev.sourcefabric.org:airtime
Conflicts: python_apps/api_clients/api_client.py
This commit is contained in:
commit
eb74c5718f
13 changed files with 124 additions and 47 deletions
|
@ -295,7 +295,7 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
|
||||
def get_shows_to_record(self):
|
||||
logger = logging.getLogger()
|
||||
response = ''
|
||||
response = None
|
||||
try:
|
||||
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["show_schedule_url"])
|
||||
#url = self.config["base_url"] + self.config["api_base"] + self.config["show_schedule_url"]
|
||||
|
@ -309,25 +309,40 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
except Exception, e:
|
||||
logger.error("Exception: %s", e)
|
||||
|
||||
return response[u'shows']
|
||||
return response
|
||||
|
||||
def upload_recorded_show(self, data, headers):
|
||||
logger = logging.getLogger()
|
||||
response = ''
|
||||
try:
|
||||
#url = self.config["base_url"] + self.config["api_base"] + self.config["upload_file_url"]
|
||||
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["upload_file_url"])
|
||||
|
||||
logger.debug(url)
|
||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||
retries = int(self.config["upload_retries"])
|
||||
retries_wait = int(self.config["upload_wait"])
|
||||
|
||||
request = urllib2.Request(url, data, headers)
|
||||
response = urllib2.urlopen(request).read().strip()
|
||||
#url = self.config["base_url"] + self.config["api_base"] + self.config["upload_file_url"]
|
||||
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["upload_file_url"])
|
||||
|
||||
logger.info("uploaded show result %s", response)
|
||||
|
||||
except Exception, e:
|
||||
logger.error("Exception: %s", e)
|
||||
logger.debug(url)
|
||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||
|
||||
for i in range(0, retries):
|
||||
logger.debug("Upload attempt: %s", i+1)
|
||||
|
||||
try:
|
||||
request = urllib2.Request(url, data, headers)
|
||||
response = urllib2.urlopen(request).read().strip()
|
||||
|
||||
logger.info("uploaded show result %s", response)
|
||||
break
|
||||
|
||||
except urllib2.HTTPError, e:
|
||||
logger.error("Http error code: %s", e.code)
|
||||
except urllib2.URLError, e:
|
||||
logger.error("Server is down: %s", e.args)
|
||||
except Exception, e:
|
||||
logger.error("Exception: %s", e)
|
||||
|
||||
#wait some time before next retry
|
||||
time.sleep(retries_wait)
|
||||
|
||||
return response
|
||||
|
||||
|
|
|
@ -84,9 +84,12 @@ class PypoFetch(Thread):
|
|||
pypo_timezone = (process.communicate()[0]).strip(' \r\n\t')
|
||||
|
||||
if server_timezone != pypo_timezone:
|
||||
logger.error("Server and pypo timezone offsets do not match. Audio playback may not start when expected!")
|
||||
logger.error("Server timezone offset: %s", server_timezone)
|
||||
logger.error("Pypo timezone offset: %s", pypo_timezone)
|
||||
logger.error("ERROR: Airtime server and pypo timezone offsets do not match. Audio playback will not start when expected!!!")
|
||||
logger.error(" * Server timezone offset: %s", server_timezone)
|
||||
logger.error(" * Pypo timezone offset: %s", pypo_timezone)
|
||||
logger.error(" * To fix this, you need to set the 'date.timezone' value in your php.ini file and restart apache.")
|
||||
logger.error(" * See this page for more info (v1.7): http://wiki.sourcefabric.org/x/BQBF")
|
||||
logger.error(" * and also the 'FAQ and Support' page underneath it.")
|
||||
|
||||
"""
|
||||
Process the schedule
|
||||
|
|
|
@ -20,3 +20,9 @@ show_schedule_url = 'recorded-shows/format/json/api_key/%%api_key%%'
|
|||
|
||||
# URL to upload the recorded show's file to Airtime
|
||||
upload_file_url = 'upload-recorded/format/json/api_key/%%api_key%%'
|
||||
|
||||
#number of retries to upload file if connection problem
|
||||
upload_retries = 3
|
||||
|
||||
#time to wait between attempts to upload file if connection problem (in seconds)
|
||||
upload_wait = 60
|
||||
|
|
|
@ -61,7 +61,7 @@ class ShowRecorder(Thread):
|
|||
filename = self.filename.replace(" ", "-")
|
||||
filepath = "%s%s.%s" % (config["base_recorded_files"], filename, self.filetype)
|
||||
|
||||
command = "ecasound -i alsa -o %s -t:%s -ge:3,1,0,-1" % (filepath, length)
|
||||
command = "ecasound -i alsa -o %s -t:%s -ge:0.1,0.1,0,-1" % (filepath, length)
|
||||
args = command.split(" ")
|
||||
|
||||
print "starting record"
|
||||
|
@ -145,6 +145,10 @@ class Record():
|
|||
def get_shows(self):
|
||||
|
||||
shows = self.api_client.get_shows_to_record()
|
||||
if shows is not None:
|
||||
shows = shows[u'shows']
|
||||
else:
|
||||
shows = []
|
||||
|
||||
if len(shows):
|
||||
self.process_shows(shows)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue