From: yomguy Date: Mon, 16 Jul 2012 09:51:12 +0000 (+0200) Subject: add rsync test to avoid multiple uploads X-Git-Tag: 0.9~61 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=017dad5c3992d11a5c7e5720a13d2372cba6c82a;p=telecaster-client.git add rsync test to avoid multiple uploads --- diff --git a/telecaster/management/commands/telecaster-rsync-archives.py b/telecaster/management/commands/telecaster-rsync-archives.py index f4c4196..bf8f598 100644 --- a/telecaster/management/commands/telecaster-rsync-archives.py +++ b/telecaster/management/commands/telecaster-rsync-archives.py @@ -17,18 +17,19 @@ class Command(BaseCommand): server = settings.TELECASTER_RSYNC_SERVER log = settings.TELECASTER_RSYNC_LOG logger = Logger(log) - command = 'rsync -aq ' - + command = 'rsync -aq ' + def handle(self, *args, **options): - stations = Station.objects.filter(started=True) - ids = [station.public_id for station in stations] - if ids: - for id in ids: - self.command += '--exclude=%s ' % id - self.command += self.archives + ' ' + self.server - try: - os.system(self.command) - self.logger.write_info(self.command) - except: - self.logger.write_error('NOT rsynced') - \ No newline at end of file + pid = get_pid('rsync') + if not pid: + stations = Station.objects.filter(started=True) + ids = [station.public_id for station in stations] + if ids: + for id in ids: + self.command += '--exclude=%s ' % id + self.command += self.archives + ' ' + self.server + try: + os.system(self.command) + self.logger.write_info(self.command) + except: + self.logger.write_error('NOT rsynced') diff --git a/telecaster/tools/tools.py b/telecaster/tools/tools.py index 1d0921f..058250f 100644 --- a/telecaster/tools/tools.py +++ b/telecaster/tools/tools.py @@ -103,14 +103,6 @@ def xml2dict(conf_file): dict = xmltodict(conf_xml,'utf-8') return dict -import psutil - -PROCNAME = "deefuzzer" -PROCARGS = ".telecaster/deefuzzer_webm.xml" - - - - def get_pid(name, args=None): """Get a process pid filtered by arguments and uid""" pids = []