Exemple #1
0
 def decode(self, message):
     mask = int(message[0])  #mascara
     filename = message[2]  #nome do arquivo
     path = message[3]  #caminho
     if mask == notify.CREATE_DIR:  #se for uma mensagem de criar pasta, chama a função que cria pasta, e assim por diante, para todas as máscaras
         util.create_folder(path, filename)
     elif mask == notify.DELETE_DIR:
         util.delete_folder(path, filename)
     elif mask == notify.CREATE_FILE:
         util.create_file(path, filename)
     elif mask == notify.DELETE_FILE:
         util.delete_file(path, filename)
     elif mask == notify.MODIFY_FILE:
         BkpSync.flag_send = 1
         time.sleep(0.5)
         util.modify_file(path, filename, self.conn)
         time.sleep(1)
         BkpSync.flag_send = 0
     elif mask == notify.DIR_MOVED_FROM:
         util.delete_folder(path, filename)
     elif mask == notify.DIR_MOVED_TO:
         util.create_folder(path, filename)
     elif mask == notify.FILE_MOVED_FROM:
         util.delete_file(path, filename)
     elif mask == notify.FILE_MOVE_TO:
         BkpSync.flag_send = 1
         time.sleep(0.5)
         util.modify_file(path, filename, self.conn)
         time.sleep(1)
         BkpSync.flag_send = 0
Exemple #2
0
def cleanup(code, log):
    if util.check_folder(os.path.join(util.get_script_path(), "tmp"), logger,
                         False, False):
        if not util.delete_folder(os.path.join(util.get_script_path(), "tmp"),
                                  logger, True):
            log.error("%s does exist and can not be deleted." %
                      os.path.join(util.get_script_path(), "tmp"))
            sys.exit(-1)
    sys.exit(code)
Exemple #3
0
        sys.exit(1)
    if result == "":
        print("%s %s is not installed." % (args.ide, args.edition))
    sys.exit(0)

# Checking folders
if not util.check_folder(os.path.join(util.get_script_path(), "output"),
                         logger, False, True):
    if not util.create_folder(os.path.join(util.get_script_path(), "output")):
        logger.error("%s does not exist and can not be created." %
                     os.path.join(util.get_script_path(), "output"))
        sys.exit(-1)

if util.check_folder(os.path.join(util.get_script_path(), "tmp"), logger,
                     False, True):
    if not util.delete_folder(os.path.join(util.get_script_path(), "tmp"),
                              logger, True):
        logger.error("%s does exist and can not be deleted." %
                     os.path.join(util.get_script_path(), "tmp"))
        sys.exit(-1)

for folder in [
        os.path.join(util.get_script_path(), "tmp"),
        os.path.join(util.get_script_path(), "tmp", "root", "usr", "share",
                     "jetbrains", args.ide),
        os.path.join(util.get_script_path(), "tmp", "root", "usr", "share",
                     "applications"),
        os.path.join(util.get_script_path(), "tmp", "root", "usr", "bin"),
        os.path.join(util.get_script_path(), "tmp", "root", "etc", args.ide),
        os.path.join(util.get_script_path(), "tmp", "root", "etc", "sysctl.d"),
        os.path.join(util.get_script_path(), "tmp", "root", "DEBIAN")
]:
def cleanup(code, log):
    if util.check_folder(os.path.join(util.get_script_path(), "tmp"), logger, False, False):
        if not util.delete_folder(os.path.join(util.get_script_path(), "tmp"), logger, True):
            log.error("%s does exist and can not be deleted." % os.path.join(util.get_script_path(), "tmp"))
            sys.exit(-1)
    sys.exit(code)
        sys.exit(-1)
    if result != version.group() and result != "":
        print("There is a newer version (%s) than installed (%s) available!" % (version.group(), result))
        sys.exit(1)
    if result == "":
        print("%s %s is not installed." % (args.ide, args.edition))
    sys.exit(0)

# Checking folders
if not util.check_folder(os.path.join(util.get_script_path(), "output"), logger, False, True):
    if not util.create_folder(os.path.join(util.get_script_path(), "output")):
        logger.error("%s does not exist and can not be created." % os.path.join(util.get_script_path(), "output"))
        sys.exit(-1)

if util.check_folder(os.path.join(util.get_script_path(), "tmp"), logger, False, True):
    if not util.delete_folder(os.path.join(util.get_script_path(), "tmp"), logger, True):
        logger.error("%s does exist and can not be deleted." % os.path.join(util.get_script_path(), "tmp"))
        sys.exit(-1)

for folder in [os.path.join(util.get_script_path(), "tmp"),
               os.path.join(util.get_script_path(), "tmp", "root", "usr", "share", "jetbrains", args.ide),
               os.path.join(util.get_script_path(), "tmp", "root", "usr", "share", "applications"),
               os.path.join(util.get_script_path(), "tmp", "root", "usr", "bin"),
               os.path.join(util.get_script_path(), "tmp", "root", "etc", args.ide),
               os.path.join(util.get_script_path(), "tmp", "root", "etc", "sysctl.d"),
               os.path.join(util.get_script_path(), "tmp", "root", "DEBIAN")]:
    if not util.create_folder(folder):
        logger.error("%s can not be created." % folder)
        sys.exit(-1)

if not util.check_folder(os.path.join(util.get_script_path(), "data"), logger, False, False):