Ejemplo n.º 1
0
def merge_decrypted(filename):
    fs = Filesplit()
    fs.merge(input_dir="cache", cleanup=True)
    dec_file = open("cache/" + filename, "rb")
    filedata = dec_file.read()
    dec_file_copy = open("decryptedFiles/" + filename, "wb")
    dec_file_copy.write(filedata)
    dec_file.close()
    dec_file_copy.close()

    return True
Ejemplo n.º 2
0
def get_model():
    """
    Loads model from the filesystem, merging it previously if needed.
    """
    model_folder = os.path.join(os.environ['CovidTools'], 'mod_split_model')
    model_path = os.path.join(model_folder, 'model.pt')
    if not os.path.exists(model_path):
        fs = Filesplit()
        fs.merge(input_dir=os.path.join(model_folder, 'parts'),
                 output_file=os.path.join(model_path),
                 cleanup=False)
    return torch.load(model_path)
ap.add_argument("-o", "--file", required=True, help="Output file name")
ap.add_argument("-l", "--log", required=False, help="When set to True, execution log is written to log_split.txt")
ap.add_argument("-c", "--clean", required=False, help="Removes split files after merging them")
args = vars(ap.parse_args())

def merge_cb(f, s):
    print("file: {0}, size: {1}".format(f, s))
    if(bool(args['log'])):
        fo = open(args['input_dir']+"\log_merge.txt","a")
        fo.write("file: {0}, size: {1}\n".format(f, s))
        fo.close()

try:
    args['input_dir'] = args['input_dir'].replace("\\","/")
    args['file'] = args['input_dir'] + "/" + args['file'] 

    if(os.path.isdir(args['input_dir'])):
        if(len(os.listdir(args['input_dir']))==0):
            raise ValueError("Input directory should not be empty! Exiting...")
    else:
        raise ValueError("Input directory path is invalid")
    
    fs = Filesplit()
    fs.merge(input_dir=args['input_dir'], output_file=args['file'], callback=merge_cb, cleanup=bool(args['clean']))
    print("Merging sucessfully completed!")

except ValueError as ve:
   print(ve)

except Exception as e:
    print("Oops!", e.__class__, "occurred.")
Ejemplo n.º 4
0
                message = open(p, "rb").read()
                print(p)
                encryption.encrypting_file(message, key, p)
                p = "../"
                os.chdir(p)
                print(os.getcwd())
                os.system("python megaauth.py")
                break
            else:
                break

    elif main_input == 2:
        fs = Filesplit()
        folder_selected = filedialog.askdirectory(
            title='Choose the directory file location')
        fs.merge(input_dir=folder_selected)
        os.chdir(folder_selected)
        os.remove("./fs_manifest.csv")
        filename = []

        #os.chdir("./output/divided")

        for file in glob.glob("*.file"):
            filename.append(file)
        for i in range(len(filename) - 1):
            os.remove(filename[i + 1])

        decrypt.decryption()

        print("Please check the download folder for the result file.")
        print("Thank for using Nightfury_Decrypto !!")
Ejemplo n.º 5
0
fluid.install_check.run_check()

# --------------------- 请你不要改 start-----------------------------
# 项目的base目录
BASE_DIR = str(Path(os.path.abspath(__file__)).parent)

# 模型文件目录
# 文本检测模型
DET_MODEL_PATH = os.path.join(BASE_DIR, 'backend', 'models', 'ch_det')
# 文本识别模型
REC_MODEL_PATH = os.path.join(BASE_DIR, 'backend', 'models', 'ch_rec')

# 查看该路径下是否有文本模型识别完整文件,没有的话合并小文件生成完整文件
if 'inference.pdiparams' not in (os.listdir(REC_MODEL_PATH)):
    fs = Filesplit()
    fs.merge(input_dir=REC_MODEL_PATH)

# 字典路径
DICT_PATH = os.path.join(BASE_DIR, 'backend', 'ppocr', 'utils',
                         'ppocr_keys_v1.txt')


# 默认字幕出现的大致区域
class SubtitleArea(Enum):
    # 字幕区域出现在下半部分
    LOWER_PART = 0
    # 字幕区域出现在上半部分
    UPPER_PART = 1
    # 不知道字幕区域可能出现的位置
    UNKNOWN = 2
    # 明确知道字幕区域出现的位置