Skip to content

Instantly share code, notes, and snippets.

@nicdk
Created June 22, 2012 11:05
Show Gist options
  • Save nicdk/2972108 to your computer and use it in GitHub Desktop.
Save nicdk/2972108 to your computer and use it in GitHub Desktop.
Patch to RSyncBackup-1.3 for Python3
--- ./RSyncBackup-1.3/lib/RSyncBackup.py 2012-02-04 09:47:48.000000000 +0900
+++ ./RSyncBackup-1.3b/lib/RSyncBackup.py 2012-06-22 19:52:35.000000000 +0900
@@ -33,7 +33,7 @@
__version__ = "1.3"
-import time, commands, re
+import time, subprocess, re
import logging
import os, os.path
@@ -67,7 +67,7 @@
lrf = open (self.lastRunFile, 'r')
oldTime = lrf.read()
lrf.close()
- except Exception, e:
+ except Exception as e:
self.log.warn ("Exception occured reading the last run file %s. Error: %s" % (self.lastRunFile, str (e)))
self.backupStarted = time.gmtime()
return 1
@@ -82,7 +82,7 @@
else:
self.log.info ("Not yet time to backup.")
return 0
- except Exception, e:
+ except Exception as e:
self.log.warn ("Exception occured parsing last run file %s. Error: %s" % (self.lastRunFile, str (e)))
self.backupStarted = time.gmtime()
return 1
@@ -126,7 +126,7 @@
if (self.testRun):
self.log.warn ("TestRun - would execute command: " + cmnd)
else:
- result = commands.getstatusoutput (cmnd)
+ result = subprocess.getstatusoutput (cmnd)
if (result[0] != 0):
self.log.error ("Error running rsync: %s" % result[1])
return 0
@@ -209,7 +209,7 @@
lrf.write (time.asctime (self.backupStarted))
lrf.close()
self.log.info ("Last Run File updated succesfully")
- except Exception, e:
+ except Exception as e:
self.log.error ("Exception occured writing the last run file %s. Error: %s" % (self.lastRunFile, str (e)))
raise Exception ("Error writing to last run file!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment