def tearDownClass(self):

        shutil.rmtree(
            ServerFiles.GetExpectedUpdateDir(
                self._file_service.GetServiceKey()))
        shutil.rmtree(
            ServerFiles.GetExpectedUpdateDir(
                self._tag_service.GetServiceKey()))
Example #2
0
 def setUpClass( self ):
     
     services = []
     
     self._file_service = ClientData.GenerateService( HydrusData.GenerateKey(), HC.FILE_REPOSITORY, 'file repo', {} )
     self._tag_service = ClientData.GenerateService( HydrusData.GenerateKey(), HC.TAG_REPOSITORY, 'tag repo', {} )
     self._admin_service = ClientData.GenerateService( HydrusData.GenerateKey(), HC.SERVER_ADMIN, 'server admin', {} )
     
     services_manager = HydrusGlobals.test_controller.GetServicesManager()
     
     services_manager._keys_to_services[ self._file_service.GetServiceKey() ] = self._file_service
     services_manager._keys_to_services[ self._tag_service.GetServiceKey() ] = self._tag_service
     services_manager._keys_to_services[ self._admin_service.GetServiceKey() ] = self._admin_service
     
     HydrusPaths.MakeSureDirectoryExists( ServerFiles.GetExpectedUpdateDir( self._file_service.GetServiceKey() ) )
     HydrusPaths.MakeSureDirectoryExists( ServerFiles.GetExpectedUpdateDir( self._tag_service.GetServiceKey() ) )
     
     permissions = [ HC.GET_DATA, HC.POST_DATA, HC.POST_PETITIONS, HC.RESOLVE_PETITIONS, HC.MANAGE_USERS, HC.GENERAL_ADMIN, HC.EDIT_SERVICES ]
     
     account_key = HydrusData.GenerateKey()
     account_type = HydrusData.AccountType( 'account', permissions, ( None, None ) )
     created = HydrusData.GetNow() - 100000
     expires = None
     used_bytes = 0
     used_requests = 0
     
     self._account = HydrusData.Account( account_key, account_type, created, expires, used_bytes, used_requests )
     
     self._access_key = HydrusData.GenerateKey()
     self._file_hash = HydrusData.GenerateKey()
     
     def TWISTEDSetup():
         
         reactor.listenTCP( HC.DEFAULT_SERVER_ADMIN_PORT, ServerServer.HydrusServiceAdmin( self._admin_service.GetServiceKey(), HC.SERVER_ADMIN, 'hello' ) )
         reactor.listenTCP( HC.DEFAULT_LOCAL_FILE_PORT, ClientLocalServer.HydrusServiceLocal( CC.LOCAL_FILE_SERVICE_KEY, HC.LOCAL_FILE, 'hello' ) )
         reactor.listenTCP( HC.DEFAULT_LOCAL_BOORU_PORT, ClientLocalServer.HydrusServiceBooru( CC.LOCAL_BOORU_SERVICE_KEY, HC.LOCAL_BOORU, 'hello' ) )
         reactor.listenTCP( HC.DEFAULT_SERVICE_PORT, ServerServer.HydrusServiceRepositoryFile( self._file_service.GetServiceKey(), HC.FILE_REPOSITORY, 'hello' ) )
         reactor.listenTCP( HC.DEFAULT_SERVICE_PORT + 1, ServerServer.HydrusServiceRepositoryTag( self._tag_service.GetServiceKey(), HC.TAG_REPOSITORY, 'hello' ) )
         
     
     reactor.callFromThread( TWISTEDSetup )
     
     time.sleep( 1 )