dirsync
Advanced tools
| Metadata-Version: 1.1 | ||
| Name: dirsync | ||
| Version: 2.0c1 | ||
| Version: 2.0 | ||
| Summary: Advanced directory tree synchronisation tool | ||
@@ -71,5 +71,7 @@ Home-page: https://bitbucket.org/tkhyn/dirsync/ | ||
| Classifier: Programming Language :: Python | ||
| Classifier: Programming Language :: Python :: 2 | ||
| Classifier: Programming Language :: Python :: 3 | ||
| Classifier: License :: OSI Approved :: MIT License | ||
| Classifier: Operating System :: OS Independent | ||
| Classifier: Development Status :: 4 - Beta | ||
| Classifier: Development Status :: 5 - Production/Stable | ||
| Classifier: Intended Audience :: Developers | ||
@@ -76,0 +78,0 @@ Classifier: Intended Audience :: End Users/Desktop |
| from .version import __version__, __version_info__ | ||
| from syncer import sync | ||
| from .syncer import sync |
+88
-74
@@ -15,2 +15,3 @@ """ | ||
| import os | ||
| import sys | ||
| import stat | ||
@@ -89,2 +90,5 @@ import time | ||
| def log(self, msg=''): | ||
| sys.stdout.write(msg + '\n') | ||
| def _compare(self, dir1, dir2): | ||
@@ -150,3 +154,3 @@ | ||
| # as there is no _only pattern detection | ||
| if file in dirs and path not in left: | ||
| if f in dirs and path not in left: | ||
| self._numdirs += 1 | ||
@@ -168,7 +172,7 @@ | ||
| if self._verbose: | ||
| print 'Creating directory %s' % self._dir2 | ||
| self.log('Creating directory %s' % self._dir2) | ||
| try: | ||
| os.makedirs(self._dir2) | ||
| except Exception, e: | ||
| print e | ||
| except Exception as e: | ||
| self.log(str(e)) | ||
| return None | ||
@@ -184,3 +188,3 @@ | ||
| if self._verbose: | ||
| print 'Source directory: %s:' % dir1 | ||
| self.log('Source directory: %s:' % dir1) | ||
@@ -194,3 +198,3 @@ self._dcmp = self._compare(dir1, dir2) | ||
| if self._verbose: | ||
| print 'Deleting %s' % fullf2 | ||
| self.log('Deleting %s' % fullf2) | ||
| try: | ||
@@ -202,4 +206,4 @@ if os.path.isfile(fullf2): | ||
| self._numdelfiles += 1 | ||
| except OSError, e: | ||
| print e | ||
| except OSError as e: | ||
| self.log(str(e)) | ||
| self._numdelffld += 1 | ||
@@ -211,8 +215,8 @@ elif os.path.isdir(fullf2): | ||
| self._numdeldirs += 1 | ||
| except shutil.Error, e: | ||
| print e | ||
| except shutil.Error as e: | ||
| self.log(str(e)) | ||
| self._numdeldfld += 1 | ||
| except Exception, e: # of any use ? | ||
| print e | ||
| except Exception as e: # of any use ? | ||
| self.log(str(e)) | ||
| continue | ||
@@ -265,3 +269,4 @@ | ||
| if self._verbose: | ||
| print 'Copying file %s from %s to %s' % (filename, dir1, dir2) | ||
| self.log('Copying file %s from %s to %s' % | ||
| (filename, dir1, dir2)) | ||
| try: | ||
@@ -273,11 +278,12 @@ # source to target | ||
| if self._forcecopy: | ||
| os.chmod(os.path.dirname(dir2_root), 0777) | ||
| # 1911 = 0o777 | ||
| os.chmod(os.path.dirname(dir2_root), 1911) | ||
| try: | ||
| os.makedirs(dir2) | ||
| except OSError, e: | ||
| print e | ||
| except OSError as e: | ||
| self.log(str(e)) | ||
| self._numdirsfld += 1 | ||
| if self._forcecopy: | ||
| os.chmod(dir2, 0777) | ||
| os.chmod(dir2, 1911) # 1911 = 0o777 | ||
@@ -292,7 +298,7 @@ sourcefile = os.path.join(dir1, filename) | ||
| self._numfiles += 1 | ||
| except (IOError, OSError), e: | ||
| print e | ||
| except (IOError, OSError) as e: | ||
| self.log(str(e)) | ||
| self._numcopyfld += 1 | ||
| elif self._copydirection == 1 or self._copydirection == 2: | ||
| if self._copydirection == 1 or self._copydirection == 2: | ||
| # target to source | ||
@@ -302,8 +308,9 @@ | ||
| if self._forcecopy: | ||
| os.chmod(os.path.dirname(self.dir1_root), 0777) | ||
| # 1911 = 0o777 | ||
| os.chmod(os.path.dirname(self.dir1_root), 1911) | ||
| try: | ||
| os.makedirs(dir1) | ||
| except OSError, e: | ||
| print e | ||
| except OSError as e: | ||
| self.log(str(e)) | ||
| self._numdirsfld += 1 | ||
@@ -313,3 +320,3 @@ | ||
| if self._forcecopy: | ||
| os.chmod(dir1, 0777) | ||
| os.chmod(dir1, 1911) # 1911 = 0o777 | ||
@@ -325,9 +332,9 @@ sourcefile = os.path.join(dir2, filename) | ||
| self._numfiles += 1 | ||
| except (IOError, OSError), e: | ||
| print e | ||
| except (IOError, OSError) as e: | ||
| self.log(str(e)) | ||
| self._numcopyfld += 1 | ||
| except Exception, e: | ||
| print 'Error copying file %s' % filename | ||
| print e | ||
| except Exception as e: | ||
| self.log('Error copying file %s' % filename) | ||
| self.log(str(e)) | ||
@@ -372,6 +379,7 @@ def _cmptimestamps(self, filest1, filest2): | ||
| if self._verbose: | ||
| print 'Updating file %s' % file2 # source to target | ||
| # source to target | ||
| self.log('Updating file %s' % file2) | ||
| try: | ||
| if self._forcecopy: | ||
| os.chmod(file2, 0666) | ||
| os.chmod(file2, 1638) # 1638 = 0o666 | ||
@@ -386,12 +394,12 @@ try: | ||
| return 0 | ||
| except (IOError, OSError), e: | ||
| print e | ||
| except (IOError, OSError) as e: | ||
| self.log(str(e)) | ||
| self._numupdsfld += 1 | ||
| return -1 | ||
| except Exception, e: | ||
| print e | ||
| except Exception as e: | ||
| self.log(str(e)) | ||
| return -1 | ||
| elif self._copydirection == 1 or self._copydirection == 2: | ||
| if self._copydirection == 1 or self._copydirection == 2: | ||
@@ -404,6 +412,7 @@ # Update file if file's modification time is older than | ||
| if self._verbose: | ||
| print 'Updating file %s' % file1 # target to source | ||
| # target to source | ||
| self.log('Updating file %s' % file1) | ||
| try: | ||
| if self._forcecopy: | ||
| os.chmod(file1, 0666) | ||
| os.chmod(file1, 1638) # 1638 = 0o666 | ||
@@ -418,9 +427,9 @@ try: | ||
| return 0 | ||
| except (IOError, OSError), e: | ||
| print e | ||
| except (IOError, OSError) as e: | ||
| self.log(str(e)) | ||
| self._numupdsfld += 1 | ||
| return -1 | ||
| except Exception, e: | ||
| print e | ||
| except Exception as e: | ||
| self.log(str(e)) | ||
| return -1 | ||
@@ -448,3 +457,3 @@ | ||
| def _dirdiff(self): | ||
| def _diff(self, dir1, dir2): | ||
| """ | ||
@@ -454,19 +463,23 @@ Private function which only does directory diff | ||
| self._dcmp = self._compare(dir1, dir2) | ||
| if self._dcmp.left_only: | ||
| print 'Only in %s' % self._dir1 | ||
| for x in self._dcmp.left_only: | ||
| print '>> %s' % x | ||
| self.log('Only in %s' % dir1) | ||
| files = [] | ||
| for x in sorted(self._dcmp.left_only): | ||
| self.log('>> %s' % x) | ||
| self.log('') | ||
| if self._dcmp.right_only: | ||
| print 'Only in', self._dir2 | ||
| for x in self._dcmp.right_only: | ||
| print '<< %s' % x | ||
| self.log('Only in %s' % dir2) | ||
| for x in sorted(self._dcmp.right_only): | ||
| self.log('<< %s' % x) | ||
| self.log('') | ||
| if self._dcmp.common: | ||
| print 'Common to %s and %s' % (self._dir1, self._dir2) | ||
| for x in self._dcmp.common: | ||
| print '-- %s' % x | ||
| self.log('Common to %s and %s' % (self._dir1, self._dir2)) | ||
| for x in sorted(self._dcmp.common): | ||
| self.log('-- %s' % x) | ||
| else: | ||
| print 'No common files or sub-directories!' | ||
| self.log('No common files or sub-directories!') | ||
@@ -487,4 +500,4 @@ def sync(self): | ||
| if self._verbose: | ||
| print 'Synchronizing directory %s with %s\n' % \ | ||
| (self._dir2, self._dir1) | ||
| self.log('Synchronizing directory %s with %s\n' % | ||
| (self._dir2, self._dir1)) | ||
| self._dirdiffcopyandupdate(self._dir1, self._dir2) | ||
@@ -504,7 +517,7 @@ | ||
| if self._verbose: | ||
| print 'Updating directory %s with %s\n' % \ | ||
| (self._dir2, self._dir1) | ||
| self.log('Updating directory %s with %s\n' % | ||
| (self._dir2, self._dir1)) | ||
| self._dirdiffandupdate(self._dir1, self._dir2) | ||
| def dirdiff(self): | ||
| def diff(self): | ||
| """ | ||
@@ -520,4 +533,5 @@ Only report difference in content between two directories | ||
| print 'Difference of directory %s from %s\n' % (self._dir2, self._dir1) | ||
| self._dirdiff() | ||
| self.log('Difference of directory %s from %s\n' % | ||
| (self._dir2, self._dir1)) | ||
| self._diff(self._dir1, self._dir2) | ||
@@ -530,26 +544,26 @@ def report(self): | ||
| print '\nPython syncer finished in %s seconds.' % tt | ||
| print '%d directories parsed, %d files copied' % \ | ||
| (self._numdirs, self._numfiles) | ||
| self.log('\nPython syncer finished in %s seconds.' % tt) | ||
| self.log('%d directories parsed, %d files copied' % | ||
| (self._numdirs, self._numfiles)) | ||
| if self._numdelfiles: | ||
| print '%d files were purged.' % self._numdelfiles | ||
| self.log('%d files were purged.' % self._numdelfiles) | ||
| if self._numdeldirs: | ||
| print '%d directories were purged.' % self._numdeldirs | ||
| self.log('%d directories were purged.' % self._numdeldirs) | ||
| if self._numnewdirs: | ||
| print '%d directories were created.' % self._numnewdirs | ||
| self.log('%d directories were created.' % self._numnewdirs) | ||
| if self._numupdates: | ||
| print '%d files were updated by timestamp.' % self._numupdates | ||
| self.log('%d files were updated by timestamp.' % self._numupdates) | ||
| # Failure stats | ||
| print '\n' | ||
| self.log('\n') | ||
| if self._numcopyfld: | ||
| print '%d files could not be copied.' % self._numcopyfld | ||
| self.log('%d files could not be copied.' % self._numcopyfld) | ||
| if self._numdirsfld: | ||
| print '%d directories could not be created.' % self._numdirsfld | ||
| self.log('%d directories could not be created.' % self._numdirsfld) | ||
| if self._numupdsfld: | ||
| print '%d files could not be updated.' % self._numupdsfld | ||
| self.log('%d files could not be updated.' % self._numupdsfld) | ||
| if self._numdeldfld: | ||
| print '%d directories could not be purged.' % self._numdeldfld | ||
| self.log('%d directories could not be purged.' % self._numdeldfld) | ||
| if self._numdelffld: | ||
| print '%d files could not be purged.' % self._numdelffld | ||
| self.log('%d files could not be purged.' % self._numdelffld) | ||
@@ -556,0 +570,0 @@ |
@@ -7,3 +7,3 @@ """ | ||
| __version_info__ = (2, 0, 0, 'rc', 1) | ||
| __version_info__ = (2, 0, 0, 'final', 0) | ||
@@ -10,0 +10,0 @@ |
+4
-2
| Metadata-Version: 1.1 | ||
| Name: dirsync | ||
| Version: 2.0c1 | ||
| Version: 2.0 | ||
| Summary: Advanced directory tree synchronisation tool | ||
@@ -71,5 +71,7 @@ Home-page: https://bitbucket.org/tkhyn/dirsync/ | ||
| Classifier: Programming Language :: Python | ||
| Classifier: Programming Language :: Python :: 2 | ||
| Classifier: Programming Language :: Python :: 3 | ||
| Classifier: License :: OSI Approved :: MIT License | ||
| Classifier: Operating System :: OS Independent | ||
| Classifier: Development Status :: 4 - Beta | ||
| Classifier: Development Status :: 5 - Production/Stable | ||
| Classifier: Intended Audience :: Developers | ||
@@ -76,0 +78,0 @@ Classifier: Intended Audience :: End Users/Desktop |
+2
-0
@@ -39,2 +39,4 @@ """ | ||
| 'Programming Language :: Python', | ||
| 'Programming Language :: Python :: 2', | ||
| 'Programming Language :: Python :: 3', | ||
| 'License :: OSI Approved :: MIT License', | ||
@@ -41,0 +43,0 @@ 'Operating System :: OS Independent', |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.