mirror of
https://github.com/nikdoof/tvorganise.git
synced 2025-12-13 06:42:16 +00:00
Merge branch 'master' of ssh://git.tensixtyone.com/code/tvorganise
This commit is contained in:
@@ -5,15 +5,31 @@ import tvorganise
|
|||||||
import unittest
|
import unittest
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import tempfile
|
||||||
|
|
||||||
class testTvOrganise(unittest.TestCase):
|
class testTvOrganise(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
Test class for TvOrganise module
|
Test class for TvOrganise module
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def setUp(self):
|
def testConfigParser(self):
|
||||||
|
"""
|
||||||
|
Simple test to check to see if the config parser actually returns a
|
||||||
|
dict on completion
|
||||||
|
"""
|
||||||
|
dict = self.tvo._get_config('tvorganise.cfg')
|
||||||
|
self.assertTrue(dict)
|
||||||
|
|
||||||
|
def testConfigSettings(self):
|
||||||
|
"""
|
||||||
|
Using a predefined dict, save then load the config and validate
|
||||||
|
the contents
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.tvo = tvorganise.TvOrganiser()
|
||||||
|
|
||||||
|
|
||||||
class testFindFiles(unittest.TestCase):
|
class testFindFiles(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -123,11 +123,11 @@ class TvOrganiser():
|
|||||||
|
|
||||||
seasno, epno = int(seasno), int(epno)
|
seasno, epno = int(seasno), int(epno)
|
||||||
|
|
||||||
self._logger.debug("File:", filename)
|
self._logger.debug("File: %s" % filename)
|
||||||
self._logger.debug("Pattern:", regex.pattern)
|
self._logger.debug("Pattern: %s" % regex.pattern)
|
||||||
self._logger.debug("Showname:", showname)
|
self._logger.debug("Showname: %s" % showname)
|
||||||
self._logger.debug("Seas:", seasno)
|
self._logger.debug("Seas: %s" % seasno)
|
||||||
self._logger.debug("Ep:", epno)
|
self._logger.debug("Ep: %s" % epno)
|
||||||
|
|
||||||
episodelist.append({'showname': showname,
|
episodelist.append({'showname': showname,
|
||||||
'seasonnum': seasno,
|
'seasonnum': seasno,
|
||||||
@@ -185,37 +185,41 @@ class TvOrganiser():
|
|||||||
newpath = config['target_path'] % name
|
newpath = config['target_path'] % name
|
||||||
newfile = os.path.join(newpath, filename)
|
newfile = os.path.join(newpath, filename)
|
||||||
|
|
||||||
self._logger.info("Old path:", oldfile)
|
self._logger.info("Old path: %s" % oldfile)
|
||||||
self._logger.info("New path:", newfile)
|
self._logger.info("New path: %s" % newfile)
|
||||||
|
|
||||||
if opts.always:
|
if opts.always:
|
||||||
if not os.path.exists(newpath):
|
if not os.path.exists(newpath):
|
||||||
os.makedirs(newpath)
|
os.makedirs(newpath)
|
||||||
if os.path.exists(newfile):
|
if os.path.exists(newfile):
|
||||||
self._logger.warning("[!] File already exists, not copying")
|
self._logger.warning("File already exists, not copying")
|
||||||
else:
|
else:
|
||||||
if same_partition(oldfile, newpath):
|
if same_partition(oldfile, newpath):
|
||||||
self._logger.info("[*] Moving file")
|
self._logger.info("Moving file")
|
||||||
try:
|
try:
|
||||||
os.rename(oldfile, newfile)
|
os.rename(oldfile, newfile)
|
||||||
except OSError, errormsg:
|
except OSError, errormsg:
|
||||||
self._logger.error("[!] Error moving file! %s" % (errormsg))
|
self._logger.error("Error moving file! %s" % errormsg)
|
||||||
else:
|
else:
|
||||||
self._logger.info("[*] Copying file")
|
self._logger.info("Copying file")
|
||||||
try:
|
try:
|
||||||
shutil.copy(oldfile, newfile)
|
shutil.copy(oldfile, newfile)
|
||||||
except IOError, errormsg:
|
except IOError, errormsg:
|
||||||
self._logger.error("[!] Error copying file! %s" % (errormsg))
|
self._logger.error("Error copying file! %s" % errormsg)
|
||||||
else:
|
else:
|
||||||
self._logger.info("[*] ..done")
|
self._logger.info("done")
|
||||||
else:
|
else:
|
||||||
self._logger.warning("Skipping file: %s" % filename)
|
self._logger.warning("Skipping file: %s" % filename)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
"""
|
||||||
|
Start a stand alone instance of TvOrganise
|
||||||
|
"""
|
||||||
|
|
||||||
logging.basicConfig(format="%(name)s:%(levelname)s: %(message)s")
|
logging.basicConfig(format="%(name)s:%(levelname)s: %(message)s")
|
||||||
|
|
||||||
t = TvOrganiser()
|
tvorg = TvOrganiser()
|
||||||
t.main()
|
tvorg.main()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user