예제 #1
0
 def test_rmdir(self):
   for sub in ("sub1", "sub2" ):
      make_a_file( self.source_dir, sub, ("FOO","BAR.JPEG"), datetime.date( 2010,10,30) )
   sorter.main( get_me_settings( os.path.join( self.source_dir, "sub1" ) ,  self.target_dir,  ) )
   check_files( self.source_dir, ("sub1/",), exists=True)
   sorter.main( get_me_settings( os.path.join( self.source_dir, "sub2" ) ,  self.target_dir, "--rmdir" ) )
   check_files( self.source_dir, ("sub2/",), exists=False)
예제 #2
0
 def test_simple(self):
   make_a_file( self.source_dir, "sub1", ("FOO","BAR") , datetime.date( 2010,10,30) )
   make_a_file( self.source_dir, "sub2", ("FOO","BAR"), datetime.date( 2010,11,30) )
   check_files( self.source_dir, ("sub1/FOO",) )
   check_files( self.source_dir, ("sub2/FOO",) )
   sorter.main( get_me_settings( self.source_dir,  self.target_dir , "--dry_run" ) )
   check_files( self.source_dir, ("sub1/FOO",) )
   check_files( self.target_dir, ("2010-10/",), exists=False )
   sorter.main( get_me_settings( self.source_dir,  self.target_dir ) )
   check_files( self.target_dir, ("2010-10/FOO", "2010-10/BAR", "2010-11/FOO", "2010-11/BAR" ) )
예제 #3
0
파일: updater.py 프로젝트: gred0216/zxcs8
def main():
    logger = set_log()
    logger.info('start logging')

    for tag in all_tag:
        update_shelf(tag)

    for sort in all_sort:
        update_shelf(sort)

    sorter.main()

    logger = set_log()
    logger.info('stop logging')
예제 #4
0
def mainLoop(downloadDirs):
    print(
        f"\n\n\nScanner set for '{downloadDirs}', it will periodicly check for updates every '{scanTime}' seconds and automatically move the new files accordingly to its appropriate folders! \n You may now minimize this app and let it run in the background"
    )
    while True:
        directoryListener = os.listdir(downloadDirs)
        time.sleep(scanTime)
        changes = 0
        errors = []
        if directoryListener != os.listdir(downloadDirs):
            try:
                changes = sorter.main(downloadDirs, False)
                print(
                    f"Scan at {datetime.datetime.now()} in '{downloadDirs}', recieved {changes} changes."
                )
            except Exception as e:
                errors.append(e)

        for e in errors:
            print(f"Uh oh an error!, here's the log: {e}")
예제 #5
0
 def test_duplicate_same_content( self ):
   for sub in ("sub1", "sub2", "sub3" ):
      make_a_file( self.source_dir, sub, ("FOO",), datetime.date( 2010,10,30), content="SAME CONTENT" )
   sorter.main( get_me_settings( self.source_dir,  self.target_dir , "--verbose" ) ) 
예제 #6
0
 def test_duplicate(self):
   for sub in ("sub1", "sub2", "sub3" ):
      make_a_file( self.source_dir, sub, ("FOO","BAR.JPEG"), datetime.date( 2010,10,30) )
   sorter.main( get_me_settings( self.source_dir,  self.target_dir , "--verbose" ) )
예제 #7
0
 def test_main(self):
     with self.assertRaises(SystemExit):
         sorter.main(['sorter.py'])
예제 #8
0
 def test_doesnt_touch_unknown_files(self):
     self.assertTrue(os.path.isfile("test.nyxie"))
     sorter.main()
     self.assertTrue(os.path.isfile("test.nyxie"))
예제 #9
0
 def test_doesnt_do_recurrsive(self):
     os.mkdir("dont-touch")
     open("dont-touch/test.pdf", "a").close()
     sorter.main()
     self.assertFalse(os.path.isdir("dont-touch/Music"))
예제 #10
0
 def test_do_nothing_if_dir_empty(self):
     os.mkdir("./empty")
     os.chdir("./empty")
     sorter.main()
     self.assertEqual(len(os.listdir('.')), 0)
     os.chdir("../")
예제 #11
0
 def test_main(self):
     with self.assertRaises(SystemExit):
         sorter.main(['sorter.py'])