Пример #1
0
def removePartialSave(streamSHA):
    '''Taking the stream SHA as an argument, this function will remove the partial save object, and well as remove any
    temporary data BitGlitter may have had with it.
    '''

    config.assembler.removePartialSave(streamSHA)
    config.saveSession()
Пример #2
0
    def cleanup(self, blockPosition=0):
        '''Removes temporary folder, updates statistics.'''

        logging.debug("Deleting temporary folder....")
        shutil.rmtree(self.activePath)

        config.saveSession()
        logging.info('Write process complete!')
Пример #3
0
def beginAssembly(streamSHA):
    '''This function exists to initiate assembly of a package at a later time, rather than doing so immediately for
    whatever reason.
    '''

    if config.assembler.saveDict[streamSHA]._attemptAssembly() == True:
        config.assembler.removePartialSave(streamSHA)
    config.saveSession()
Пример #4
0
def removeCustomPaletteNickname(idOrNick):
    '''Removes the palette nickname from the corresponding dictionary.  This does not delete the palette, only the
    nickname.
    '''

    tempHolder = _dictPopper(idOrNick)
    tempHolder.nickname = ""
    config.colorHandler.customPaletteList[tempHolder.id] = tempHolder
    config.saveSession()
Пример #5
0
def clearCustomPaletteNicknames():
    '''Clears all custom palette nicknames.  This does not delete the palettes themselves.'''

    config.colorHandler.customPaletteNicknameList = {}

    for palette in config.colorHandler.customPaletteList:

        tempHolder = config.colorHandler.customPaletteList.pop(palette)
        tempHolder.nickname = ""
        config.colorHandler.customPaletteList[tempHolder.id] = tempHolder

    config.saveSession()
Пример #6
0
def _addCustomPaletteDirect(name, description, colorSet, distance, dateCreated, id, nickname=None):
    '''After validation is done, this function is ran to actually instantiate the palette object, as well as load it
    into the appropriate dictionaries and save the configuration file.  This should never be ran by itself because it
    blindly accepts all values!
    '''

    newPalette = CustomPalette(name, description, colorSet, distance, dateCreated, id, nickname)
    config.colorHandler.customPaletteList[id] = newPalette

    if nickname:
        config.colorHandler.customPaletteNicknameList[nickname] = newPalette

    config.saveSession()
Пример #7
0
def editNicknameToCustomPalette(idOrNick, newName):
    '''This changes the nickname of the given palette to something new, first checking if it's valid.'''

    if newName not in config.colorHandler.customPaletteList \
            and newName not in config.colorHandler.customPaletteNicknameList \
            and newName not in config.colorHandler.defaultPaletteList:

        tempHolder = _dictPopper(idOrNick)
        tempHolder.nickname = newName
        config.colorHandler.customPaletteList[tempHolder.id] = tempHolder
        config.colorHandler.customPaletteNicknameList[tempHolder.nickname] = tempHolder
        config.saveSession()

    else:
        raise ValueError(f"'{newName}' is already being used, please try another.")
Пример #8
0
def read(fileToInput,
         outputPath = None,
         badFrameStrikes = BAD_FRAME_STRIKES,
         assembleHold = False,

         # Geometry Overrides
         blockHeightOverride = False,
         blockWidthOverride = False,

         # Crypto Input
         encryptionKey = None,
         scryptN = SCRYPT_N_DEFAULT,
         scryptR = SCRYPT_R_DEFAULT,
         scryptP = SCRYPT_P_DEFAULT,

         # Logging Settings
         loggingLevel = 'info',
         loggingScreenOutput = True,
         loggingSaveOutput = False
         ):
    '''This is the high level function that decodes BitGlitter encoded images and video back into the files/folders
    contained within them.  This along with write() are the two primary functions of this library.
    '''

    # Logging initializing.
    loggingSetter(loggingLevel, loggingScreenOutput, loggingSaveOutput)
    from bitglitter.read.fileslicer import fileSlicer
    from bitglitter.config.config import config

    # Are all parameters acceptable?
    verifyReadParameters(fileToInput, outputPath, encryptionKey, scryptN, scryptR, scryptP, blockWidthOverride,
                         blockWidthOverride, assembleHold)

    # This sets the name of the temporary folder while screened data from partial saves is being written.
    activePath = READ_PATH

    # Pull valid frame data from the inputted file.
    checkpointPassed = fileSlicer(fileToInput, activePath, outputPath, blockHeightOverride, blockWidthOverride,
                                  encryptionKey, scryptN, scryptR, scryptP, config, badFrameStrikes, assembleHold)
    if checkpointPassed == False:
        return False

    # Now that all frames have been scanned, we'll have the config object check to see if any files are ready for
    # assembly.  If there are, they will be put together and outputted, as well as removed/flushed from partialSaves.
    config.assembler.reviewActiveSessions()
    config.saveSession()
    return True
Пример #9
0
def updatePartialSave(streamSHA, reattemptAssembly = True, passwordUpdate = None, scryptN =  None,
                      scryptR = None, scryptP = None, changeOutputPath = None):
    '''This function will update the PartialSave object with the parameters provided, once they've been verified.'''

    if passwordUpdate:
        properStringSyntax('passwordUpdate', passwordUpdate)
    if scryptN:
        isIntOverZero('scryptN', scryptN)
    if scryptR:
        isIntOverZero('scryptR', scryptR)
    if scryptP:
        isIntOverZero('scryptP', scryptP)
    if changeOutputPath:
        isValidDirectory('changeOutputPath', changeOutputPath)

    config.assembler.saveDict[streamSHA].userInputUpdate(passwordUpdate, scryptN, scryptR, scryptP, changeOutputPath)

    if reattemptAssembly == True:
        if config.assembler.saveDict[streamSHA]._attemptAssembly() == True:
            config.assembler.removePartialSave(streamSHA)

    config.saveSession()
Пример #10
0
def removeCustomPalette(idOrNick):
    '''Removes custom palette completely from the config file.'''

    _dictPopper(idOrNick)
    config.saveSession()
Пример #11
0
def clearAllCustomPalettes():
    '''Removes all custom palettes from both the ID dictionary and nickname dictionary.'''

    config.colorHandler.customPaletteNicknameList = {}
    config.colorHandler.customPaletteList = {}
    config.saveSession()
Пример #12
0
def removeAllPartialSaves():
    '''This removes all partial save objects saved, as well as any temporary data.'''

    config.assembler.clearPartialSaves()
    config.saveSession()
Пример #13
0
def clearStats():
    '''Resets statistics back to zero in all fields.'''

    config.statsHandler.clearStats()
    config.saveSession()