From 684694d7d21bf7f08c48ab5ef3fec521b5ae15ce Mon Sep 17 00:00:00 2001 From: yomguy Date: Mon, 21 Sep 2009 21:20:39 +0000 Subject: [PATCH] avoid 'LIVE' telecaster process to be parsed by get_id() --- station.py | 2 +- telecaster.py | 2 +- tools/tools.py | 15 +++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/station.py b/station.py index a97fdf1..63b4a7d 100644 --- a/station.py +++ b/station.py @@ -81,7 +81,7 @@ class Station(Conference): self.output_dir = self.media_dir + os.sep + self.department + os.sep + self.date self.file_dir = self.output_dir + os.sep + self.ServerName self.uid = os.getuid() - self.odd_pid = get_pid('^oddcastv3 -n [^LIVE]', self.uid) + self.odd_pid = get_pid('^oddcastv3\ -n', self.uid) self.rip_pid = get_pid('streamripper ' + self.url + self.mount_point, self.uid) self.new_title = clean_string('_-_'.join(self.server_name)+'_-_'+self.session+'_-_'+self.professor+'_-_'+self.comment) self.short_title = clean_string('_-_'.join(self.conference)+'_-_'+self.session+'_-_'+self.professor+'_-_'+self.comment) diff --git a/telecaster.py b/telecaster.py index 4b14edb..43732d8 100755 --- a/telecaster.py +++ b/telecaster.py @@ -58,7 +58,7 @@ class TeleCaster: self.uid = os.getuid() def main(self): - odd_pid = get_pid('^oddcastv3 -n [^LIVE]', self.uid) + odd_pid = get_pid('^oddcastv3\ -n', self.uid) rip_pid = get_pid('streamripper ', self.uid) writing = False casting = False diff --git a/tools/tools.py b/tools/tools.py index 89fcfa1..9e84050 100644 --- a/tools/tools.py +++ b/tools/tools.py @@ -63,12 +63,15 @@ def xml2dict(conf_file): def get_pid(proc,uid): """Get a process pid filtered by arguments and uid""" - (list1, list2) = os.popen4('pgrep -n -f -U '+str(uid)+' '+'"'+proc+'"') - pids = list2.readlines() - if pids != '': - for pid in pids: - index = pids.index(pid) - pids[index] = pid[:-1] + (list1, list2) = os.popen4('pgrep -fl -U '+str(uid)+' '+'"'+proc+'"') + procs = list2.readlines() + pids = [] + if procs != '': + for proc in procs: + pid = proc.split(' ')[0] + command = ' '.join(proc.split(' ')[1:])[:-1] + if not 'LIVE' in command: + pids.append(pid) return pids def get_params_from_lock(lock_file): -- 2.39.5