| |
- IndexedRedis.IndexedRedisModel(builtins.object)
-
- NetFetchFile
- builtins.Exception(builtins.BaseException)
-
- InvalidPasswordException
- NoSuchNetFetchFile
class InvalidPasswordException(builtins.Exception) |
|
Raised when an invalid password is provided, or some other password-related failure.
Message contains exact reason. |
|
- Method resolution order:
- InvalidPasswordException
- builtins.Exception
- builtins.BaseException
- builtins.object
Data descriptors defined here:
- __weakref__
- list of weak references to the object (if defined)
Methods inherited from builtins.Exception:
- __init__(self, /, *args, **kwargs)
- Initialize self. See help(type(self)) for accurate signature.
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Methods inherited from builtins.BaseException:
- __delattr__(self, name, /)
- Implement delattr(self, name).
- __getattribute__(self, name, /)
- Return getattr(self, name).
- __reduce__(...)
- __repr__(self, /)
- Return repr(self).
- __setattr__(self, name, value, /)
- Implement setattr(self, name, value).
- __setstate__(...)
- __str__(self, /)
- Return str(self).
- with_traceback(...)
- Exception.with_traceback(tb) --
set self.__traceback__ to tb and return self.
Data descriptors inherited from builtins.BaseException:
- __cause__
- exception cause
- __context__
- exception context
- __dict__
- __suppress_context__
- __traceback__
- args
|
class NetFetchFile(IndexedRedis.IndexedRedisModel) |
|
NetFetchFile - Represents a File stored in NetFetch.
A file is keyed based on hostname and absolute filename.
May optionally have mode,owner,group filled-in.
May be encrypted with a password, in which case "encrypted" is set to "1". |
|
- Method resolution order:
- NetFetchFile
- IndexedRedis.IndexedRedisModel
- builtins.object
Methods defined here:
- encryptData(self, password)
- encryptData - Encrypts data on this object and sets 'encrypted' flag. Does not save object.
@param password <str> 4-32 characters of password, used to encrypt.
@raises - ValueError if password does not meet requirements
- getData(self, password=None)
- getData - Fetch the data associated with this file, and potentially decrypt.
@param password <str/None> - None if unencrypted, otherwise a password 4-32 chars.
@return <bytes> - file data
@raises InvalidPasswordException - The file was encrypted and a password was invalid, or the file was not encrypted and a password was provided, or the file was encrypted and no password was provided.
@raises ValueError - If password is not 4-32 characters.
- setData(self, data)
- setData - Store data on this object and calculates checksum. If a password is required, must also call encryptData. Does not save object.
@param data <bytes> - Data to store
Class methods defined here:
- create(filename, data, mode='', owner='', group='', password=None, hostnameOverride=None) from builtins.type
- create - Create and save NetFetchFile object
@param filename <str> - filename to use for storage
@param data <bytes> - Data to str
@param mode <str> - String or int of base-8 encoded chmod value. os.stat(x).st_mode returns this.
@param owner <str> - Username owner
@param group <str> - Associated group
@param password <str/None> - If provided, 4-32 characters to encrypt. If not provided, file will not be encrypted.
@param hostnameOverride <None/Str> - Override hostname with this value. Default is to use current hostname.
@return - Saved NetFetchFile object
@raises KeyError if a hostname/filename pair already exists. use createOrUpdate to conditionally update it.
@raises ValueError if provided password does not meet criteria
- createOrUpdate(filename, data, mode='', owner='', group='', password=None, hostnameOverride=None) from builtins.type
- createOrUpdate - Create and save NetFetchFile object, or update an existing one.
@param filename <str> - filename to use for storage
@param data <bytes> - Data to str
@param mode <str> - String or int of base-8 encoded chmod value. os.stat(x).st_mode returns this.
@param owner <str> - Username owner
@param group <str> - Associated group
@param password <str/None> - If provided, 4-32 characters to encrypt. If not provided, file will not be encrypted.
@param hostnameOverride <None/Str> - Override hostname with this value. Default is to use current hostname.
@return - Saved NetFetchFile object
@raises ValueError if provided password does not meet criteria
- createOrUpdateFromFile(filename, password=None, hostnameOverride=None, savePermissions=True) from builtins.type
- createOrUpdateFromFile - Create and save NetFetchFile object, or update an existing one, provided with a filename.
@param filename <str> - filename to use for storage
@param password <str/None> - If provided, 4-32 characters to encrypt. If not provided, file will not be encrypted.
@param hostnameOverride <None/Str> - Override hostname with this value. Default is to use current hostname.
@param savePermissions <bool> Default True - If True, will store owner/group/mode of file.
@return - Saved NetFetchFile object
@raises ValueError if provided password does not meet criteria
- downloadToLocal(hostname, filename, password=None, localFilename=None, retainPermissions=True) from builtins.type
- downloadToLocal - Download file to a local filename
@param hostname <str> - Hostname that file was stored on
@param filename <str> - Filename to fetch
@param password <str/None> - Try this password on potentially encrpyted file.
@param localFilename <str/None> - If defined, saves at this location. Otherwise, saves at #filename
@param retainPermissions <bool> Default True - If True, tries to retain owner/group/mode. If owner/group, you must be root. Silently fails if can't apply.
@raises NoSuchNetFetchFile - If no hostname/filename match exists
@raises InvalidPasswordException - If password was invalid, see getData for all conditions.
- downloadToStr(hostname, filename, password=None) from builtins.type
- downloadToStr - Download a hostname/filename pair and return as a string
@param hostname <str> - Hostname that file was stored on
@param filename <str> - Filename to fetch
@param password <str/None> - Try this password on potentially encrpyted file.
@return <bytes> - Data that has been downloaded
@raises NoSuchNetFetchFile - If no hostname/filename match exists
@raises InvalidPasswordException - If password was invalid, see getData for all conditions.
- exists(hostname, filename) from builtins.type
- exists - Check if a hostname/filename pair exists
@param hostname <str> - Hostname field
@param filename <str> - Filename field
@return <bool> - If a file is stored under the hostname/filename key pair
Static methods defined here:
- calculateChecksum(data)
- calculateChecksum - Calculates a checksum from given data
@param data <bytes> - Data to check
Data and other attributes defined here:
- BASE64_FIELDS = ['data']
- FIELDS = ['filename', 'hostname', 'checksum', 'encrypted', 'mode', 'owner', 'group', 'data']
- INDEXED_FIELDS = ['filename', 'hostname']
- KEY_NAME = 'NetFetchFile'
Methods inherited from IndexedRedis.IndexedRedisModel:
- __getstate__(self)
- pickle uses this
- __init__(self, *args, **kwargs)
- __init__ - Set the values on this object. MAKE SURE YOU CALL THE SUPER HERE, or else things will not work.
- __repr__(self)
- __repr__ - Returns a string of the constructor/params to recreate this object.
Example: objCopy = eval(repr(obj))
@return - String of python init call to recreate this object
- __setstate__(self, stateDict)
- pickle uses this
- __str__(self)
- __str__ - Returns a string representation of this object's state.
See implementation.
@return <str>-
Some samples:
(Pdb) str(z)
'<Song obj _id=24 at 0x7f3c6a3a4490>'
(Pdb) z.artist = 'New Artist'
(Pdb) str(z)
'<Song obj _id=24 (Unsaved Changes) at 0x7f3c6a3a4490>'
- asDict(self, includeMeta=False)
- toDict / asDict - Get a dictionary representation of this model.
@param includeMeta - Include metadata in return. For now, this is only pk stored as "_id"
@return - Dictionary reprensetation of this object and all fields
- copy(self, copyPrimaryKey=False)
- copy - Copies this object.
@param copyPrimaryKey <bool> default False - If True, any changes to the copy will save over-top the existing entry in Redis.
If False, only the data is copied, and nothing is saved.
- delete(self)
- delete - Delete this object
- getPk(self)
- getPk - Gets the internal primary key associated with this object
- getUpdatedFields(self)
- getUpdatedFields - See changed fields.
@return - a dictionary of fieldName : tuple(old, new)
- hasUnsavedChanges(self)
- hasUnsavedChanges - Check if any unsaved changes are present in this model, or if it has never been saved.
@return <bool> - True if any fields have changed since last fetch, or if never saved. Otherwise, False
- reload(self)
- reload - Reload this object from the database.
@raises KeyError - if this object has not been saved (no primary key)
@return - True if any updates occured, False if data remained the same.
- save(self)
- save - Save this object
- saveToExternal(self, redisCon)
- saveToExternal - Saves this object to a different Redis than that specified by REDIS_CONNECTION_PARAMS on this model.
@param redisCon <dict/redis.Redis> - Either a dict of connection params, a la REDIS_CONNECTION_PARAMS, or an existing Redis connection.
If you are doing a lot of bulk copies, it is recommended that you create a Redis connection and pass it in rather than establish a new
connection with each call.
@note - You will generate a new primary key relative to the external Redis environment. If you need to reference a "shared" primary key, it is better
to use an indexed field than the internal pk.
- toDict = asDict(self, includeMeta=False)
- toDict / asDict - Get a dictionary representation of this model.
@param includeMeta - Include metadata in return. For now, this is only pk stored as "_id"
@return - Dictionary reprensetation of this object and all fields
Class methods inherited from IndexedRedis.IndexedRedisModel:
- reset(newValues) from builtins.type
- validateModel() from builtins.type
- validateModel - Class method that validates a given model is implemented correctly. Will only be validated once, on first model instantiation.
@param model - Implicit of own class
@return - True
@raises - InvalidModelException if there is a problem with the model, and the message contains relevant information.
Data descriptors inherited from IndexedRedis.IndexedRedisModel:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes inherited from IndexedRedis.IndexedRedisModel:
- REDIS_CONNECTION_PARAMS = {}
- deleter = <IndexedRedis.IndexedRedisDelete object>
- objects = <IndexedRedis.IndexedRedisQuery object>
- saver = <IndexedRedis.IndexedRedisSave object>
|
class NoSuchNetFetchFile(builtins.Exception) |
|
Raised when a file attempted to be fetched does not exist |
|
- Method resolution order:
- NoSuchNetFetchFile
- builtins.Exception
- builtins.BaseException
- builtins.object
Data descriptors defined here:
- __weakref__
- list of weak references to the object (if defined)
Methods inherited from builtins.Exception:
- __init__(self, /, *args, **kwargs)
- Initialize self. See help(type(self)) for accurate signature.
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Methods inherited from builtins.BaseException:
- __delattr__(self, name, /)
- Implement delattr(self, name).
- __getattribute__(self, name, /)
- Return getattr(self, name).
- __reduce__(...)
- __repr__(self, /)
- Return repr(self).
- __setattr__(self, name, value, /)
- Implement setattr(self, name, value).
- __setstate__(...)
- __str__(self, /)
- Return str(self).
- with_traceback(...)
- Exception.with_traceback(tb) --
set self.__traceback__ to tb and return self.
Data descriptors inherited from builtins.BaseException:
- __cause__
- exception cause
- __context__
- exception context
- __dict__
- __suppress_context__
- __traceback__
- args
| |