From 82f964c4f63435adb4f6b335abd4533a95faf9c7 Mon Sep 17 00:00:00 2001 From: Patrick Linstruth Date: Mon, 2 Sep 2019 08:22:30 -0700 Subject: [PATCH 1/4] Refactored 'pypad_tunein.py' ProcessPad while loop. --- ChangeLog | 2 ++ apis/pypad/scripts/pypad_tunein.py | 57 +++++++++++++++++------------- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index f2209b9c..4cbb7ad0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19070,3 +19070,5 @@ * Fixed an indentation error in 'apis/pypad/scripts/pypad_tunein.py'. 2019-08-31 Fred Gleason * Incremented the package version to 3.0.3int1. +2019-09-02 Patrick Linstruth + * Refactored 'pypad_tunein.py' ProcessPad while loop. diff --git a/apis/pypad/scripts/pypad_tunein.py b/apis/pypad/scripts/pypad_tunein.py index fec55a4c..2c58069a 100755 --- a/apis/pypad/scripts/pypad_tunein.py +++ b/apis/pypad/scripts/pypad_tunein.py @@ -31,31 +31,38 @@ import configparser def ProcessPad(update): if update.hasPadType(pypad.TYPE_NOW): - section='Station'+str(n) - n=1 - while(update.config().has_section(section)): - values={} - values['id']=update.config().get(section,'StationID') - values['partnerId']=update.config().get(section,'PartnerID') - values['partnerKey']=update.config().get(section,'PartnerKey') - values['title']=update.resolvePadFields(update.config().get(section,'TitleString'),pypad.ESCAPE_NONE) - values['artist']=update.resolvePadFields(update.config().get(section,'ArtistString'),pypad.ESCAPE_NONE) - values['album']=update.resolvePadFields(update.config().get(section,'AlbumString'),pypad.ESCAPE_NONE) - update.syslog(syslog.LOG_INFO,'Updating TuneIn: artist='+values['artist']+' title='+values['title']+' album='+values['album']) - try: - response=requests.get('http://air.radiotime.com/Playing.ashx',params=values) - response.raise_for_status() - except requests.exceptions.RequestException as e: - update.syslog(syslog.LOG_WARNING,str(e)) - else: - xml=ET.fromstring(response.text) - status=xml.find('./head/status') - if(status.text!='200'): - update.syslog(syslog.LOG_WARNING,'Update Failed: '+xml.find('./head/fault').text) - n=n+1 - section='Station'+str(n) - if(n==1): - update.syslog(syslog.LOG_WARNING,'No station config found') + n=1 + while(True): + section='Station'+str(n) + try: + values={} + values['id']=update.config().get(section,'StationID') + values['partnerId']=update.config().get(section,'PartnerID') + values['partnerKey']=update.config().get(section,'PartnerKey') + values['title']=update.resolvePadFields(update.config().get(section,'TitleString'),pypad.ESCAPE_NONE) + values['artist']=update.resolvePadFields(update.config().get(section,'ArtistString'),pypad.ESCAPE_NONE) + values['album']=update.resolvePadFields(update.config().get(section,'AlbumString'),pypad.ESCAPE_NONE) + except configparser.NoSectionError: + if(n==1): + update.syslog(syslog.LOG_WARNING,'No station config found') + return + + # + # Now, send the update + # + if update.shouldBeProcessed(section): + update.syslog(syslog.LOG_INFO,'Updating TuneIn: artist='+values['artist']+' title='+values['title']+' album='+values['album']) + try: + response=requests.get('http://air.radiotime.com/Playing.ashx',params=values) + response.raise_for_status() + except requests.exceptions.RequestException as e: + update.syslog(syslog.LOG_WARNING,str(e)) + else: + xml=ET.fromstring(response.text) + status=xml.find('./head/status') + if(status.text!='200'): + update.syslog(syslog.LOG_WARNING,'Update Failed: '+xml.find('./head/fault').text) + n=n+1 # # Program Name From 45d0518b1e5eb930a378afe769973c460d08bd6a Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Mon, 2 Sep 2019 11:31:23 -0400 Subject: [PATCH 2/4] 2019-09-02 Fred Gleason * Removed text labels from the transport button in the cue editor in rdairplay(1). --- ChangeLog | 3 +++ lib/librd_cs.ts | 12 ------------ lib/librd_de.ts | 12 ------------ lib/librd_es.ts | 12 ------------ lib/librd_fr.ts | 8 ++------ lib/librd_nb.ts | 12 ------------ lib/librd_nn.ts | 12 ------------ lib/librd_pt_BR.ts | 12 ------------ lib/rdcueedit.cpp | 6 +++--- 9 files changed, 8 insertions(+), 81 deletions(-) diff --git a/ChangeLog b/ChangeLog index ca339e1a..3dc49427 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19074,3 +19074,6 @@ * Remove deleted scheduler codes from rdlogmanager(1) events. * Changed empty scheduler code selection from "" to "[none]" in rdlogmanager(1) event editor. +2019-09-02 Fred Gleason + * Removed text labels from the transport button in the cue + editor in rdairplay(1). diff --git a/lib/librd_cs.ts b/lib/librd_cs.ts index 5e3a5c13..cd4ce2a7 100644 --- a/lib/librd_cs.ts +++ b/lib/librd_cs.ts @@ -1239,18 +1239,6 @@ ze &souboru RDCueEdit - - &Audition - - - - &Pause - - - - &Stop - - Start diff --git a/lib/librd_de.ts b/lib/librd_de.ts index 16b5bd26..661161f1 100644 --- a/lib/librd_de.ts +++ b/lib/librd_de.ts @@ -1230,18 +1230,6 @@ senden RDCueEdit - - &Audition - - - - &Pause - - - - &Stop - - Start diff --git a/lib/librd_es.ts b/lib/librd_es.ts index cd065c63..0b1b7f7f 100644 --- a/lib/librd_es.ts +++ b/lib/librd_es.ts @@ -1230,18 +1230,6 @@ Color RDCueEdit - - &Audition - - - - &Pause - - - - &Stop - - Start diff --git a/lib/librd_fr.ts b/lib/librd_fr.ts index 3db0a25a..3460176b 100644 --- a/lib/librd_fr.ts +++ b/lib/librd_fr.ts @@ -1116,17 +1116,13 @@ La Couleur RDCueEdit - - &Audition - - &Pause - &Pause + &Pause &Stop - &Stop + &Stop Start diff --git a/lib/librd_nb.ts b/lib/librd_nb.ts index 79858fc7..a3c5b201 100644 --- a/lib/librd_nb.ts +++ b/lib/librd_nb.ts @@ -1229,18 +1229,6 @@ farge RDCueEdit - - &Audition - - - - &Pause - - - - &Stop - - Start diff --git a/lib/librd_nn.ts b/lib/librd_nn.ts index 79858fc7..a3c5b201 100644 --- a/lib/librd_nn.ts +++ b/lib/librd_nn.ts @@ -1229,18 +1229,6 @@ farge RDCueEdit - - &Audition - - - - &Pause - - - - &Stop - - Start diff --git a/lib/librd_pt_BR.ts b/lib/librd_pt_BR.ts index ebd44143..2ab041c8 100644 --- a/lib/librd_pt_BR.ts +++ b/lib/librd_pt_BR.ts @@ -1230,18 +1230,6 @@ Cor RDCueEdit - - &Audition - - - - &Pause - - - - &Stop - - Start diff --git a/lib/rdcueedit.cpp b/lib/rdcueedit.cpp index 65cb77f8..a1850f8d 100644 --- a/lib/rdcueedit.cpp +++ b/lib/rdcueedit.cpp @@ -118,7 +118,7 @@ RDCueEdit::RDCueEdit(RDCae *cae,int card,int port,QWidget *parent) edit_audition_button-> setPalette(QPalette(backgroundColor(),QColor(Qt::gray))); edit_audition_button->setFont(button_font); - edit_audition_button->setText(tr("&Audition")); + // edit_audition_button->setText(tr("&Audition")); connect(edit_audition_button,SIGNAL(clicked()), this,SLOT(auditionButtonData())); @@ -130,7 +130,7 @@ RDCueEdit::RDCueEdit(RDCae *cae,int card,int port,QWidget *parent) edit_pause_button-> setPalette(QPalette(backgroundColor(),QColor(Qt::gray))); edit_pause_button->setFont(button_font); - edit_pause_button->setText(tr("&Pause")); + // edit_pause_button->setText(tr("&Pause")); connect(edit_pause_button,SIGNAL(clicked()),this,SLOT(pauseButtonData())); // @@ -142,7 +142,7 @@ RDCueEdit::RDCueEdit(RDCae *cae,int card,int port,QWidget *parent) edit_stop_button-> setPalette(QPalette(backgroundColor(),QColor(Qt::gray))); edit_stop_button->setFont(button_font); - edit_stop_button->setText(tr("&Stop")); + // edit_stop_button->setText(tr("&Stop")); connect(edit_stop_button,SIGNAL(clicked()),this,SLOT(stopButtonData())); // From 1b70e21d0edbe8acb859a6e92b538b55570d2f7e Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Mon, 2 Sep 2019 11:39:28 -0400 Subject: [PATCH 3/4] 2019-09-02 Fred Gleason * Fixed a bug in the 'pypad' module that caused the DB connection to be opened in 'latin1' mode. --- ChangeLog | 3 +++ apis/pypad/api/pypad.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3dc49427..5642137c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19077,3 +19077,6 @@ 2019-09-02 Fred Gleason * Removed text labels from the transport button in the cue editor in rdairplay(1). +2019-09-02 Fred Gleason + * Fixed a bug in the 'pypad' module that caused the DB connection + to be opened in 'latin1' mode. diff --git a/apis/pypad/api/pypad.py b/apis/pypad/api/pypad.py index b1684423..1835f190 100644 --- a/apis/pypad/api/pypad.py +++ b/apis/pypad/api/pypad.py @@ -797,7 +797,9 @@ class Receiver(object): def __openDb(self): creds=self.__getDbCredentials() - return MySQLdb.connect(creds[2],creds[0],creds[1],creds[3]) + return MySQLdb.connect(user=creds[0],password=creds[1], + host=creds[2],database=creds[3], + charset='utf8mb4') def setPadCallback(self,callback): """ From a6c1361d43a955aad7c1bfbbbcec91cefd7b12fe Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Mon, 2 Sep 2019 11:46:59 -0400 Subject: [PATCH 4/4] 2019-09-02 Fred Gleason * Modified the 'pypad' module so as not to throw a 'UnicodeDecodeError' exception when processing a PAD update containing an invalid UTF-8 character. --- ChangeLog | 4 ++++ apis/pypad/api/pypad.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5642137c..581e53a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19080,3 +19080,7 @@ 2019-09-02 Fred Gleason * Fixed a bug in the 'pypad' module that caused the DB connection to be opened in 'latin1' mode. +2019-09-02 Fred Gleason + * Modified the 'pypad' module so as not to throw a + 'UnicodeDecodeError' exception when processing a PAD update + containing an invalid UTF-8 character. diff --git a/apis/pypad/api/pypad.py b/apis/pypad/api/pypad.py index 1835f190..b6a5bdd7 100644 --- a/apis/pypad/api/pypad.py +++ b/apis/pypad/api/pypad.py @@ -908,8 +908,9 @@ class Receiver(object): c=sock.recv(1) line+=c if c[0]==10: - msg+=line.decode('utf-8') - if line.decode('utf-8')=="\r\n": + linebytes=line.decode('utf-8','replace') + msg+=linebytes + if linebytes=='\r\n': self.__pypad_Process(Update(json.loads(msg),self.__config_parser,rd_config)) msg="" line=bytes()