Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
QP.AddToLayout( gridbox, self._button_5 )
QP.AddToLayout( gridbox, self._button_6 )
QP.AddToLayout( gridbox, self._button_1 )
QP.AddToLayout( gridbox, self._button_2 )
QP.AddToLayout( gridbox, self._button_3 )
self.setLayout( gridbox )
( width, height ) = ClientGUIFunctions.ConvertTextToPixels( self, ( 64, 14 ) )
self.setMinimumWidth( width )
self.setMinimumHeight( height )
self._services = HG.client_controller.services_manager.GetServices()
repository_petition_permissions = [ ( content_type, HC.PERMISSION_ACTION_OVERRULE ) for content_type in HC.REPOSITORY_CONTENT_TYPES ]
self._petition_service_keys = [ service.GetServiceKey() for service in self._services if service.GetServiceType() in HC.REPOSITORIES and True in ( service.HasPermission( content_type, action ) for ( content_type, action ) in repository_petition_permissions ) ]
self._InitButtons( 'home' )
self._button_7.clicked.connect( lambda: self._HitButton( 7 ) )
self._button_8.clicked.connect( lambda: self._HitButton( 8 ) )
self._button_9.clicked.connect( lambda: self._HitButton( 9 ) )
self._button_4.clicked.connect( lambda: self._HitButton( 4 ) )
self._button_5.clicked.connect( lambda: self._HitButton( 5 ) )
self._button_6.clicked.connect( lambda: self._HitButton( 6 ) )
self._button_1.clicked.connect( lambda: self._HitButton( 1 ) )
self._button_2.clicked.connect( lambda: self._HitButton( 2 ) )
self._button_3.clicked.connect( lambda: self._HitButton( 3 ) )
if not request.requestHeaders.hasHeader( 'Content-Type' ):
parsed_request_args = HydrusNetworking.ParsedRequestArguments()
total_bytes_read = 0
else:
content_types = request.requestHeaders.getRawHeaders( 'Content-Type' )
content_type = content_types[0]
try:
mime = HC.mime_enum_lookup[ content_type ]
except:
raise HydrusExceptions.BadRequestException( 'Did not recognise Content-Type header!' )
total_bytes_read = 0
if mime == HC.APPLICATION_JSON:
json_bytes = request.content.read()
total_bytes_read += len( json_bytes )
json_string = str( json_bytes, 'utf-8' )
cl = ServiceLocalRatingLike
elif service_type == HC.LOCAL_RATING_NUMERICAL:
cl = ServiceLocalRatingNumerical
elif service_type in HC.REPOSITORIES:
cl = ServiceRepository
elif service_type in HC.RESTRICTED_SERVICES:
cl = ServiceRestricted
elif service_type == HC.IPFS:
cl = ServiceIPFS
elif service_type in HC.REMOTE_SERVICES:
cl = ServiceRemote
elif service_type == HC.LOCAL_BOORU:
cl = ServiceLocalBooru
elif service_type == HC.CLIENT_API_SERVICE:
cl = ServiceClientAPI
else:
def _CheckValid( self ):
path = self._path.GetPath()
if path in ( '', None ):
raise HydrusExceptions.VetoException( 'You must enter a path to import from!' )
if not os.path.exists( path ):
QW.QMessageBox.warning( self, 'Warning', 'The path you have entered--"'+path+'"--does not exist! The dialog will not force you to correct it, but this import folder will do no work as long as the location is missing!' )
if HC.BASE_DIR.startswith( path ) or HG.client_controller.GetDBDir().startswith( path ):
raise HydrusExceptions.VetoException( 'You cannot set an import path that includes your install or database directory!' )
if self._action_successful.GetValue() == CC.IMPORT_FOLDER_MOVE:
path = self._location_successful.GetPath()
if path in ( '', None ):
raise HydrusExceptions.VetoException( 'You must enter a path for your successful file move location!' )
if not os.path.exists( path ):
QW.QMessageBox.warning( self, 'Warning', 'The path you have entered for your successful file move location--"'+path+'"--does not exist! The dialog will not force you to correct it, but you should not let this import folder run until you have corrected or created it!' )
def _InitialiseMagicMimeScores( self ):
# let's render our thumbs in order of ease of regeneration, so we rush what we can to screen as fast as possible and leave big vids until the end
for mime in HC.ALLOWED_MIMES:
self._magic_mime_thumbnail_ease_score_lookup[ mime ] = 5
# default filetype thumbs are easiest
self._magic_mime_thumbnail_ease_score_lookup[ None ] = 0
self._magic_mime_thumbnail_ease_score_lookup[ HC.APPLICATION_UNKNOWN ] = 0
for mime in HC.APPLICATIONS:
self._magic_mime_thumbnail_ease_score_lookup[ mime ] = 0
for mime in HC.AUDIO:
def _GetDefaultTagImportOptionsForURL( self, url ):
url_class = self._GetURLClass( url )
if url_class is None or url_class.GetURLType() not in ( HC.URL_TYPE_POST, HC.URL_TYPE_WATCHABLE ):
return self._file_post_default_tag_import_options
try:
( url_class, url ) = self._GetNormalisedAPIURLClassAndURL( url )
except HydrusExceptions.URLClassException:
return self._file_post_default_tag_import_options
# some lad decided to api convert one url type to another
if url_class.GetURLType() not in ( HC.URL_TYPE_POST, HC.URL_TYPE_WATCHABLE ):
if len( deletee_paths ) > 0:
HydrusData.Print( 'Export folder {} deleted {} files and {} folders.'.format( self._name, HydrusData.ToHumanInt( len( deletee_paths ) ), HydrusData.ToHumanInt( len( deletee_dirs ) ) ) )
if self._delete_from_client_after_export:
deletee_hashes = { media_result.GetHash() for media_result in media_results }
chunks_of_hashes = HydrusData.SplitListIntoChunks( deletee_hashes, 64 )
reason = 'Deleted after export to Export Folder "{}".'.format( self._path )
content_updates = [ HydrusData.ContentUpdate( HC.CONTENT_TYPE_FILES, HC.CONTENT_UPDATE_DELETE, chunk_of_hashes, reason = reason ) for chunk_of_hashes in chunks_of_hashes ]
for content_update in content_updates:
HG.client_controller.WriteSynchronous( 'content_updates', { CC.LOCAL_FILE_SERVICE_KEY : [ content_update ] } )
def GetDefaultLaunchPath():
if HC.PLATFORM_WINDOWS:
return 'windows is called directly'
elif HC.PLATFORM_MACOS:
return 'open "%path%"'
elif HC.PLATFORM_LINUX:
return 'xdg-open "%path%"'
elif HC.PLATFORM_HAIKU:
return 'open "%path%"'
def _threadDoGETJob( self, request ):
self._checkBandwidth( request )
# no permissions check as any functional account can get updates
update_hash = request.parsed_request_args[ 'update_hash' ]
if not self._service.HasUpdateHash( update_hash ):
raise HydrusExceptions.NotFoundException( 'This update hash does not exist on this service!' )
path = ServerFiles.GetFilePath( update_hash )
response_context = HydrusServerResources.ResponseContext( 200, mime = HC.APPLICATION_OCTET_STREAM, path = path )
return response_context