Пример #1
0
def find_31():
    if (('wpa.dbl.bak' in datastore.SYSTEMROOT_FILE_SET)
            or ('sslkey.exe' in datastore.SYSTEMROOT_FILE_SET)):
        return True
    if ('WindowsUpdate.old' in datastore.SYSPATH_FILE_SET):
        return True
    if utils.file_exists(('%s\\temp' % datastore.SYSPATH_STR), '~MS1E.tmp'):
        return True
    if utils.file_exists(('%s\\temp' % datastore.SYSPATH_STR), '~FMIFEN.tmp'):
        return True
    (cmdStatus, cmdId) = dsz.cmd.RunEx(
        'registryquery -hive L -key "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Streams\\Desktop"',
        dsz.RUN_FLAG_RECORD)
    if (not cmdStatus):
        return False
    try:
        subkeys = set(
            dsz.cmd.data.Get('key::subkey::name', dsz.TYPE_STRING, cmdId))
    except:
        subkeys = None
    if (subkeys is not None):
        search_set = set(('Default Statusbar Sign', 'Default MenuBars Sign',
                          'Default Taskbar Sign', 'Default Zone'))
        if (not subkeys.isdisjoint(search_set)):
            return True
    return False
Пример #2
0
def dump_database():
    dumpfile = os.path.join(dconf.DB_DUMP_DIR, dconf.DB_NAME + '.dump')
    if dconf.DB_TYPE == 'oracle':
        if not dconf.ORACLE_FLASH_BACK and file_exists(dumpfile):
            LOG.info('%s already exists ! ', dumpfile)
            return False
    else:
        if file_exists(dumpfile):
            LOG.info('%s already exists ! ', dumpfile)
            return False

    if dconf.ORACLE_FLASH_BACK:
        LOG.info('create restore point %s for database %s in %s',
                 dconf.RESTORE_POINT, dconf.DB_NAME, dconf.RECOVERY_FILE_DEST)
    else:
        LOG.info('Dump database %s to %s', dconf.DB_NAME, dumpfile)

    if dconf.DB_TYPE == 'oracle':
        if dconf.ORACLE_FLASH_BACK:
            run_sql_script('createRestore.sh', dconf.RESTORE_POINT,
                           dconf.RECOVERY_FILE_DEST_SIZE,
                           dconf.RECOVERY_FILE_DEST)
        else:
            run_sql_script('dumpOracle.sh', dconf.DB_USER, dconf.DB_PASSWORD,
                           dconf.DB_NAME, dconf.DB_DUMP_DIR)

    elif dconf.DB_TYPE == 'postgres':
        run('PGPASSWORD={} pg_dump -U {} -h {} -F c -d {} > {}'.format(
            dconf.DB_PASSWORD, dconf.DB_USER, dconf.DB_HOST, dconf.DB_NAME,
            dumpfile))
    else:
        raise Exception("Database Type {} Not Implemented !".format(
            dconf.DB_TYPE))
    return True
Пример #3
0
def find_21():
    if utils.file_exists(('%s\\temp' % datastore.SYSPATH_STR),
                         'temp56273.pdf'):
        return True
    for ud in datastore.USER_DIRS_LIST:
        if utils.file_exists(('%s\\%s\\Local Settings\\History\\cache' %
                              (datastore.PROFILE_PATH, ud)), 'iecache.dll'):
            return True
    return False
Пример #4
0
def process_file(file_path):
    utils.file_exists(file_path)
    filename, mod_time = utils.get_file_metadata(file_path)
    file_hash = utils.get_file_hash(filename, mod_time)
    if data.logic.file_already_proccessed(file_hash):
        log.info('The file {} has been already processed')
    else:
        log.info('Start processing {}'.format(filename))
        data.logic.create_file_processed(file_hash, filename, mod_time)
        input_records = utils.parse_csv(file_path)
        records_with_candidates = data.logic.infer_candidates(input_records)
        process_rows(file_hash, records_with_candidates)
        log.info('Finished processing {}'.format(filename))
def build_gradle_file_exists(package_path):
    '''
    From a given package path, searches for "build.gradle" file (groovy) or
    "build.kts" file (kotlin).
    Returns True if exists, Otherwise, returns False

    '''
    if file_exists(package_path, "build.gradle") is True:
        return True
    elif file_exists(package_path, "build.gradle.kts") is True:
        return True
    else:
        return False
Пример #6
0
def backup(version):
    if not utils.file_exists(db_file):
        log.info("ERROR: unable to find the database at " + db_file)
        exit()
    backup_db_file = conf["constants"]["tmp_dir"] + "/dump.rdb_" + str(version)
    log.info("Backing up the database " + db_file + " into " + backup_db_file)
    run_command("cp -f " + db_file + " " + backup_db_file)
    if utils.file_exists(conf["constants"]["config_file"]):
        backup_config_file = conf["constants"][
            "tmp_dir"] + "/config.json_" + str(version)
        log.info("Backing up the configuration file " +
                 conf["constants"]["config_file"] + " into " +
                 backup_config_file)
        run_command("cp -f " + conf["constants"]["config_file"] + " " +
                    backup_config_file)
Пример #7
0
async def main():
    call_args = get_args()
    config_env(call_args.random_seed, call_args.log_level)

    # Kaggle stores compressed files with ".zip" suffix
    dataset_file_path: Path = call_args.storage_path / (DATASET_FILE + ".zip")
    await load_dataset(
        ds_name=call_args.dataset_name,
        ds_file_name=DATASET_FILE,
        ds_file_path=dataset_file_path,
    )

    embeddings_arch = call_args.storage_path / "glove.840B.300d.zip"
    emb_file_path = await get_embeddings(emb_arch_path=embeddings_arch)

    # Check if preprocessing could be skipped
    checksum_key = (
        f"{dataset_file_path.name}_{DATASET_SIZE}_{emb_file_path.name}_{call_args.train_size}_{call_args.random_seed}"
    )
    need_rerun = True
    if CHECKSUMS.get(checksum_key, None):
        need_rerun = False
        for f_name, checksum in CHECKSUMS.get(checksum_key).items():
            f_path = call_args.work_store_path / f_name
            if not file_exists(f_path) or not verify_checksum(f_path, checksum):
                need_rerun = True
                break
    if need_rerun:
        objects_to_save = preprocess_data(dataset_file_path, DATASET_SIZE, emb_file_path, call_args.train_size)
        dump(dump_root=call_args.work_store_path, objects=objects_to_save)
    else:
        logging.info(f"All checksums match run configuration, skipping preprocessing.")
Пример #8
0
 def _move_data(self):
     dens_orig = os.path.join(__class__._config['tmp_density_dir'],
                              self.molID + '.wb97x')
     ddsc_orig = os.path.join(__class__._config['tmp_density_dir'],
                              self.molID + '.ddsc')
     while True:
         time.sleep(__class__._config['dormi_short'])
         allfile = True
         for filep in [dens_orig, ddsc_orig]:
             try:
                 file_exists(filep)
             except FileNotFoundError:
                 allfile = False
         if allfile: break
     shutil.move(dens_orig, self._wb97x_saves)
     shutil.move(ddsc_orig, self._ddsc_saves)
def gradlew_file_exists(package_path):
    '''
    From a given package path, searches for "gradlew" file.
    Returns True if exists. Otherwise, returns False

    '''
    return file_exists(package_path, "gradlew")
Пример #10
0
def restore_database():
    dumpfile = os.path.join(dconf.DB_DUMP_DIR, dconf.DB_NAME + '.dump')
    if not dconf.ORACLE_FLASH_BACK and not file_exists(dumpfile):
        raise FileNotFoundError(
            "Database dumpfile '{}' does not exist!".format(dumpfile))

    LOG.info('Start restoring database')
    if dconf.DB_TYPE == 'oracle':
        if dconf.ORACLE_FLASH_BACK:
            run_sql_script('flashBack.sh', dconf.RESTORE_POINT)
            clean_recovery()
        else:
            drop_user()
            create_user()
            run_sql_script('restoreOracle.sh', dconf.DB_USER, dconf.DB_NAME)
    elif dconf.DB_TYPE == 'postgres':
        drop_database()
        create_database()
        run('PGPASSWORD={} pg_restore -U {} -h {} -n public -j 8 -F c -d {} {}'
            .format(dconf.DB_PASSWORD, dconf.DB_USER, dconf.DB_HOST,
                    dconf.DB_NAME, dumpfile))
    else:
        raise Exception("Database Type {} Not Implemented !".format(
            dconf.DB_TYPE))
    LOG.info('Finish restoring database')
Пример #11
0
    def install(self):
        posix_file = os.path.join(self.inst_dir, 'bin/vtkpython')
        nt_file = os.path.join(self.inst_dir, 'bin', 'vtkpython.exe')

        if utils.file_exists(posix_file, nt_file):
            utils.output("VTK already installed.  Skipping build step.")

        else:
            # python 2.5.2 setup.py complains that this does not exist
            # with VTK PV-3-2-1.  This is only on installations with
            # EasyInstall / Python Eggs, then the VTK setup.py uses
            # EasyInstall and not standard distutils.  gah!
            if not os.path.exists(config.VTK_PYTHON):
                os.makedirs(config.VTK_PYTHON)

            os.chdir(self.build_dir)

            # we save, set and restore the PP env variable, else
            # stupid setuptools complains
            save_env = os.environ.get('PYTHONPATH', '')
            os.environ['PYTHONPATH'] = config.VTK_PYTHON
            ret = utils.make_command('VTK.sln', install=True)
            os.environ['PYTHONPATH'] = save_env

            if ret != 0:
                utils.error("Could not install VTK.  Fix and try again.")
Пример #12
0
def find_22():
    if utils.file_exists(('%s\\etc' % datastore.DRIVERPATH_STR),
                         'network.ics'):
        return True
    if ('acelpvc.dll' in datastore.SYSTEMROOT_FILE_SET):
        return True
    (cmdStatus, cmdId) = dsz.cmd.RunEx(
        'registryquery -hive L -key "Software\\Sun\\1.1.2"',
        dsz.RUN_FLAG_RECORD)
    if (not cmdStatus):
        return False
    try:
        subkeys = dsz.cmd.data.Get('key::subkey::name', dsz.TYPE_STRING, cmdId)
    except RuntimeError:
        subkeys = None
    if (subkeys is not None):
        if (('AppleTlk' in subkeys) or ('IsoTp' in subkeys)):
            return True
    try:
        values = dsz.cmd.data.Get('key::value::name', dsz.TYPE_STRING, cmdId)
    except RuntimeError:
        values = None
    if (values is not None):
        if (('AppleTlk' in values) or ('IsoTp' in values)):
            return True
    return False
Пример #13
0
 def move_temp_assets(self):
     """
     Moves any temporary assets to the project directory
     :return:
     """
     import ntpath
     from shutil import copyfile
     import os
     from utils import file_exists
     script = self.get_script_instance()
     targets = script.get_targets()
     model_id = script.model_id
     client = self.client
     project_path = self.path
     for t in targets:
         target_col = t['column']
         model_filepath = get_model_filepath(client, model_id, target_col)
         model_filename = ntpath.basename(model_filepath)
         model_source = get_local_model_source(model_filepath)
         dest_model_path = os.path.join(project_path, model_filename)
         if model_source.exists():
             # We copy the model to our project dir
             model_source.copy_to(dest_model_path)
         # Pipeline
         pipeline_file = get_pipeline_latest('tpot', target_col, client)
         if pipeline_file is not None:
             pipeline_filename = ntpath.basename(pipeline_file)
             dest_pipeline_file = os.path.join(project_path,
                                               pipeline_filename)
             if file_exists(pipeline_file):
                 copyfile(pipeline_file, dest_pipeline_file)
def bower_json_exists(package_path):
    '''
    From a given package path, searches for "bower.json" file.
    Returns True if exists, Otherwise, returns False

    '''
    return file_exists(package_path, "bower.json")
Пример #15
0
def prep_r2_with_barcode(fq1, fq2, out_file):

    safe_makedir(os.path.dirname(out_file))
    if file_exists(out_file):
        print ("%s and %s have already been barcode-prepped, skipping."
               % (fq1, fq2))
        return out_file

    with open_fastq(fq1) as r1_file, open_fastq(fq2) as r2_file:
        with file_transaction(out_file) as tx_out_file:
            out_handle = open(tx_out_file, "w")
            read_count = 0
            buf = list()
            r1_r2 = itertools.izip(r1_file, r2_file)
            for header1, header2 in r1_r2:
                seq1, seq2 = r1_r2.next()
                plus1, plus2 = r1_r2.next()
                qual1, qual2 = r1_r2.next()

                read_name1, read_name2 = header1.split()[0][1:], header2.split()[0][1:]
                assert read_name1 == read_name2, "FASTQ files may be out of order."
                seq2, qual2 = seq2.rstrip(), qual2.rstrip()
                barcode, seq, qual = mask(seq1[0:6], qual1[0:6], min_qual=10) + \
                                     mask(seq1[6:], qual1[6:]), seq2, qual2
                barcoded_name = ":".join([read_name2, barcode])

                print(format_fastq([barcoded_name, seq, qual]), file=out_handle)
            out_handle.close()
    return out_file
Пример #16
0
def main() -> None:
    try:
        # Raises an HTTPError exception if moodle is not properly up
        get_moodlepage().raise_for_status()

        # Create a .env file if it doesn't exist
        if not file_exists(".env"):
            create_default_env_file()
            log_with_time("The '.env' file has been created")

        # Get our session set up
        user_credentials = get_env_netname_credentials()
        session = get_session(user_credentials)

        # Get the fetch_and_notify function running repeatedly
        log_with_time("Starting scheduler")
        scheduler = sched.scheduler()
        scheduler.enter(0, 1, fetch_and_notify, (session, scheduler))
        scheduler.run()
    except HTTPError as e:
        log_with_time(f"HTTPError occured (status code is 4xx or 5xx):\n{e}")
    except (ConnectionError, Timeout) as e:
        log_with_time(
            f"Moodle website appears to be down (ConnectionError or Timeout):\n{e}"
        )
    except Exception as e:
        log_with_time(f"Exception:\n{e}")

    log_with_time(
        f"Rescheduling the main method to run in {get_scheduler_delay()} seconds"
    )
    scheduler = sched.scheduler()
    scheduler.enter(get_scheduler_delay(), 1, main)
    scheduler.run()
Пример #17
0
    def calculate_rel_blast_matrix(self):
        file_name = '{}-{}-{}_scores.npy'.format(self.org1.org_id,
                                                 self.org2.org_id, 'rel_blast')

        if utils.file_exists(file_name, path_name=cs.NP_PATH):
            message = 'using saved relative blast from {}'.format(file_name)
            utils.print_log(message)

            self.blast_sim_n_rel = utils.load_np(self.np_file)
            self.blast_sim = utils.load_np(self.raw_np_file)
            # self.blast_sim = interface.blast_xml_to_matrix(self)

        else:
            # blast similarity measure
            blast_sim = interface.blast_xml_to_matrix(self)
            self.blast_sim = blast_sim

            blast_1 = interface.self_blast_xml_to_vec(self.org1)
            blast_1[blast_1 == 0] = 1
            blast_1 = np.array([blast_1]).repeat(self.org2.node_count,
                                                 axis=0).T

            blast_2 = interface.self_blast_xml_to_vec(self.org2)
            blast_2[blast_2 == 0] = 1
            blast_2 = np.array([blast_2]).repeat(self.org1.node_count, axis=0)

            blast_sim = blast_sim.reshape(self.org1.node_count,
                                          self.org2.node_count)
            blast_sim = blast_sim / np.power((blast_1 * blast_2), 0.5)
            blast_sim = blast_sim.reshape(self.dim_sim)

            # normalize blast matrix
            self.blast_sim_n_rel = utils.normalize(blast_sim)
            np_file = utils.join_path(cs.NP_PATH, file_name)
            utils.write_np(self.blast_sim_n_rel, np_file)
Пример #18
0
    def install(self):
        posix_file = os.path.join(self.inst_dir, 'bin/vtkpython')
        nt_file = os.path.join(self.inst_dir, 'bin', 'vtkpython.exe')

        if utils.file_exists(posix_file, nt_file):    
            utils.output("VTK already installed.  Skipping build step.")

        else:
            # python 2.5.2 setup.py complains that this does not exist
            # with VTK PV-3-2-1.  This is only on installations with
            # EasyInstall / Python Eggs, then the VTK setup.py uses
            # EasyInstall and not standard distutils.  gah!
            if not os.path.exists(config.VTK_PYTHON):
                os.makedirs(config.VTK_PYTHON)

            os.chdir(self.build_dir)

            # we save, set and restore the PP env variable, else
            # stupid setuptools complains
            save_env = os.environ.get('PYTHONPATH', '')
            os.environ['PYTHONPATH'] = config.VTK_PYTHON
            ret = utils.make_command('VTK.sln', install=True)
            os.environ['PYTHONPATH'] = save_env

            if ret != 0:
                utils.error("Could not install VTK.  Fix and try again.")
Пример #19
0
    def install(self):
        config.WRAPITK_TOPLEVEL = self.inst_dir
        # this dir contains the WrapITK cmake config (WrapITKConfig.cmake)
        config.WRAPITK_DIR = os.path.join(
                self.inst_dir, 'lib', 'InsightToolkit', 'WrapITK')
        # contains all WrapITK shared objects / libraries
        config.WRAPITK_LIB = os.path.join(config.WRAPITK_DIR, 'lib')
        # contains itk.py
        config.WRAPITK_PYTHON = os.path.join(config.WRAPITK_DIR, 'Python')
        # subsequent wrapitk components will need this
        config.WRAPITK_SOURCE_DIR = self.source_dir

        posix_file = os.path.join(
                config.WRAPITK_LIB, '_RegistrationPython.so')
        nt_file = os.path.join(
                config.WRAPITK_LIB, '_RegistrationPython' + config.PYE_EXT)

        if utils.file_exists(posix_file, nt_file):
            utils.output("WrapITK already installed, skipping step.")
        else:
            os.chdir(self.build_dir)
            ret = utils.make_command('WrapITK.sln', install=True)

            if ret != 0:
                utils.error(
                "Could not install WrapITK.  Fix and try again.")
Пример #20
0
def package_lock_json_exists(package_path):
    '''
    From a given package path, searches for "package-lock.json" file.
    Returns True if exists, Otherwise, returns False

    '''
    return file_exists(package_path, "package-lock.json")
Пример #21
0
def make_dataset(classlist):
    filename = '/tmp/folderlist.pkl'
    if utils.file_exists(filename):
        print("loading from cache")
        pickle_load = pickle.load(open(filename, "rb"))
        images = pickle_load["images"]
        labels = pickle_load["labels"]
    else:
        print("cache not found, generating cache, this will take a while")
        images = []
        labels = []
        classes = utils.readtextfile(classlist)
        classes = [x.rstrip('\n') for x in classes]
        classes.sort()

        for index in range(len(classes)):
            for fname in os.listdir(classes[index]):
                if is_image_file(fname):
                    fname = os.path.join(classes[index], fname)
                    images.append(fname)
                    labels.append(index)

        pickle_save = {"images": images, "labels": labels}
        pickle.dump(pickle_save, open(filename, "wb"))
    return images, labels
Пример #22
0
def npm_shrinkwrap_json_exists(package_path):
    '''
    From a given package path, searches for "npm-shrinkwrap.json" file.
    Returns True if exists, Otherwise, returns False

    '''
    return file_exists(package_path, "npm-shrinkwrap.json")
def yarn_lock_exists(package_path):
    '''
    From a given package path, searches for "package.json" file.
    Returns True if exists, Otherwise, returns False

    '''
    return file_exists(package_path, "yarn.lock")
def pom_xml_exists(package_path):
    '''
    From a given package path, searches for "pom.xml" file.
    Returns True if exists. Otherwise, returns False

    '''
    return file_exists(package_path, "pom.xml")
Пример #25
0
def find_04():
    if ('$NtUninstallQ817473$' in datastore.SYSPATH_FILE_SET):
        return True
    for f in ['Hd1', 'Hd2', 'IdeDrive1', 'IdeDrive2']:
        if utils.file_exists('\\\\.', (f + '\\')):
            return True
    return False
Пример #26
0
    def __init__(self, filep):
        uts.file_exists(filep)
        self.config = dict(basis_set='6-31G')

        self.atoms = []
        self.x = []
        self.y = []
        self.z = []
        self.charge = ''
        self.multiplicity = ''
        self.title = 'Should be setted!'

        self._template()

        self._basis_set_conversion(self.config['basis_set'])
        self._read_xyz(filep)
Пример #27
0
 def _move_data(self):
     dens_orig = os.path.join(config['temporary_densities_repo'],
                              self.molID + '.wb97x')
     ddsc_orig = os.path.join(config['temporary_densities_repo'],
                              self.molID + '.ddsc')
     while True:
         time.sleep(config['wait_to_recheck'])
         allfile = True
         for filep in [dens_orig, ddsc_orig]:
             try:
                 file_exists(filep)
             except FileNotFoundError:
                 allfile = False
         if allfile: break
     shutil.move(dens_orig, self._wb97x_saves)
     shutil.move(ddsc_orig, self._ddsc_saves)
Пример #28
0
def find_28():
    for ud in datastore.USER_DIRS_LIST:
        if utils.file_exists(
            ('%s\\%s\\Local Settings\\Application Data' %
             (datastore.PROFILE_PATH, ud)),
                'S-1-5-31-1286970278978-5713669491-166975984-320'):
            return True
    return False
Пример #29
0
def find_08():
    if ('s7otbxsx.dll' in datastore.SYSTEMROOT_FILE_SET):
        return True
    if ('mrxcls' in datastore.SERVICE_NAME_SET):
        return True
    if utils.file_exists(('%s\\inf' % datastore.SYSPATH_STR), 'mdmcpq3.pnf'):
        return True
    return False
Пример #30
0
def download_file(file_url, dest_dir, md5, aspera):
    if utils.file_exists(file_url, dest_dir, md5):
        return
    success = attempt_file_download(file_url, dest_dir, md5, aspera)
    if not success:
        success = attempt_file_download(file_url, dest_dir, md5, aspera)
    if not success:
        print 'Failed to download file after two attempts'
Пример #31
0
    def on_epoch_end(self, epoch, logs=None):
        # Saving training history
        # Check if directory exists
        directory_path = settings.TRAINED_MODELS_PATH + self.model_name
        if not file_exists(directory_path):
            create_dir(directory_path)

        # Word level history
        if self.word_level:
            hist_path = settings.TRAINED_MODELS_PATH + self.model_name + "/" + self.model_name + "word.pkl"
            average_accuracy = 0
            if file_exists(hist_path):
                acc_loss_history = load_pickle_data(hist_path)
            else:
                acc_loss_history = dict()
                acc_loss_history["accuracy"] = []
                acc_loss_history["loss"] = []

                # Average accuracy
            for i in range(0, 6):
                accuracy = "decoder_dense" + str(i) + "_acc"
                average_accuracy += logs[accuracy]

            average_accuracy = float(average_accuracy) / float(6)

            acc_loss_history["accuracy"].append(average_accuracy)
            acc_loss_history["loss"].append(logs["loss"])

        # Character level history
        else:
            hist_path = settings.TRAINED_MODELS_PATH + self.model_name + "/" + self.model_name + "char.pkl"
            if file_exists(hist_path):
                acc_loss_history = load_pickle_data(hist_path)
            else:
                acc_loss_history = dict()
                acc_loss_history["accuracy"] = []
                acc_loss_history["loss"] = []

            acc_loss_history["accuracy"].append(logs["acc"])
            acc_loss_history["loss"].append(logs["loss"])

        generate_pickle_file(acc_loss_history, hist_path)
        plot_train_loss_acc(hist_path, self.word_level)

        self.model.save(self.model_path)
Пример #32
0
def find_44():
    filesinsys32 = ['rasmgr.dll', 'raseap.dll']
    otherfiles = ['%windir%\\AppPatch\\rasmain.sdb']
    results = []
    for f in filesinsys32:
        results.append((f in datastore.SYSPATH_FILE_SET))
    for f in otherfiles:
        results.append(file_exists(*os.path.split(f)))
    return any(results)
Пример #33
0
def load_local_dataset():
    if file_exists(TRAIN_PERSIST_PATH):
        print('Loading dataset from npy file')
        return load_data(), get_speakers()
    else:
        print('Reading and tranforming dataset')
        train = read_dataset_dir(DATASET_TRAIN_PATH)
        save_data(train)
        return train, get_speakers()
Пример #34
0
    def deserialize(self):
        """ Deserialize the client object from storage.

        """

        if utils.file_exists(self._storage):
            glbl.LOG.debug(
                ('deserializing user from `{}` ...').format(self._storage))
            self.__dict__.update(
                pickle.load(open(self._storage, 'rb')).__dict__)
Пример #35
0
def test_convert_audio_failure():
    desired_format = 'ttt'

    try:
        convert_audio(ffmpeg_binary, input_file, desired_format, output_file)
    except ConvertAudioException:
        pass

    new_file_exists = file_exists(output_file)
    assert (new_file_exists == False)
Пример #36
0
def count_umi(sam_file, gtf_file, barcode_to_well, multimappers=False):
    """
    stripped down implementation of the HTSeq algorithm for counting
    """
    base, _ = os.path.splitext(sam_file)
    out_file = base + ".counts"
    out_umi_file = base + ".counts_umi.gz"
    out_umi_pos_file = base + ".counts_umi_pos.gz"
    if file_exists(out_file):
        return out_file
    wells = sorted(barcode_to_well.values())
    seen_umi = defaultdict(set)
    seen_umi_list = defaultdict(Counter)
    seen_umi_pos_list = defaultdict(Counter)
    exons = HTSeq.GenomicArrayOfSets("auto", stranded=False)
    gtf_handle = HTSeq.GFF_Reader(gtf_file)
    for feature in gtf_handle:
        if feature.type == "exon":
            exons[feature.iv] += feature.attr["gene_id"]

    sam_handle = HTSeq.SAM_Reader(sam_file)
    for read in sam_handle:
        if not read.aligned:
            continue
        if not multimappers:
            try:
                if read.optional_field("NH") > 1:
                    continue
            except KeyError:
                pass
        iv_seq = (co.ref_iv for co in read.cigar if co.type == "M" and co.size > 0)
        fs = set()
        for iv in iv_seq:
            for iv2, fs2 in exons[iv].steps():
                if not fs:
                    fs = fs2.copy()
                else:
                    fs = fs.intersection(fs2)
        if len(fs) == 1:
            fields = read.original_sam_line.split("\t")
            position = "%s:%s" % (fields[2], fields[3])
            barcode, umi = get_barcode_and_umi(read)
            if barcode not in barcode_to_well:
                continue
            seen_umi[(list(fs)[0], barcode_to_well[barcode])].add(umi)
            seen_umi_list[(list(fs)[0], barcode_to_well[barcode])][umi] += 1
            seen_umi_pos_list[(position, barcode_to_well[barcode], list(fs)[0])][umi] += 1
    write_extensive_summary(seen_umi_list, out_umi_file)
    write_extensive_summary_by_pos(seen_umi_pos_list, out_umi_pos_file)
    with file_transaction(out_file) as tx_out_file:
            with open(tx_out_file, "w") as out_handle:
                print("\t".join(["feature"] + wells), file=out_handle)
                for feature in get_feature_names(gtf_file):
                    counts = [len(seen_umi[(feature, well)]) for well in wells]
                    print("\t".join([feature] + map(str, counts)), file=out_handle)
Пример #37
0
	def OkPressed(self):
		from utils import file_exists
		from alert import ErrorDialog
		fileName = self.GetFileName()
		if file_exists(fileName) == 0:
			str = 'File ' + fileName + ' not found.'
			errorDlg = ErrorDialog(self.top, str)
			errorDlg.Show()
			errorDlg.DialogCleanup()
			return
		FileDialog.OkPressed(self)
Пример #38
0
    def install(self):
        posix_file = os.path.join(self.inst_dir, 'bin/ErGUI')
        nt_file = os.path.join(self.inst_dir, 'bin', 'ErGUI.exe')

        if utils.file_exists(posix_file, nt_file):    
            utils.output("Template Workbench already installed. Skipping install step.")

        else:
			ret = utils.make_command('ErGUI.sln', install=True)
			if ret != 0:
				utils.error("Could not install Template Workbench. Fix and try again.")
Пример #39
0
	def OkPressed(self):
		from utils import file_exists
		from alert import WarningDialog
		fileName = self.GetFileName()
		if file_exists(fileName) == 1:
			str = 'File ' + fileName + ' exists.\nDo you wish to overwrite it?'
			warningDlg = WarningDialog(self.top, str)
			if warningDlg.Show() == 0:
				warningDlg.DialogCleanup()
				return
			warningDlg.DialogCleanup()
		FileDialog.OkPressed(self)
Пример #40
0
    def deserialize(self):
        """ Deserialize the client object from storage.

        """

        if utils.file_exists(self._storage):
            glbl.LOG.debug((
                'deserializing user from `{}` ...'
            ).format(self._storage))
            self.__dict__.update(
                pickle.load(open(self._storage, 'rb')).__dict__
            )
Пример #41
0
    def build(self):
        posix_file = os.path.join(self.build_dir, "lib/_ItkVtkGluePython.so")
        nt_file = os.path.join(self.build_dir, "lib", config.BUILD_TARGET, "_ItkVtkGluePython" + config.PYE_EXT)

        if utils.file_exists(posix_file, nt_file):
            utils.output("ItkVtkGlue already built.  Skipping build step.")

        else:
            os.chdir(self.build_dir)
            ret = utils.make_command("ItkVtkGlue.sln")
            if ret != 0:
                utils.error("Could not build ItkVtkGlue.  Fix and try again.")
    def build(self):
        bin_path = os.path.join(self.build_dir, 'apps', 'tighten', 'RelWithDebInfo')

        if utils.file_exists(bin_path, bin_path):    
            utils.output("%s already built.  Skipping build step." % BASENAME)

        else:
            os.chdir(self.build_dir)
            ret = utils.make_command('VispackMorphsmooth.sln')

            if ret != 0:
                utils.error("Could not build %s.  Fix and try again." % BASENAME)
Пример #43
0
 def build(self):
     posix_file = os.path.join(config.QT_BUILD_BIN, 'libQtCore4.so') #TODO:
     nt_file = os.path.join(config.QT_BUILD_BIN, 'QtCore4.dll')
     if utils.file_exists(posix_file, nt_file):    
         utils.output("%s already built.  Skipping build step." % BASENAME)
         return
     
     os.chdir(self.build_dir)
     ret = utils.execute_in_vs_environment('nmake')
     
     if ret != 0:
         utils.error("Could not build %s.  Fix and try again." % BASENAME)
Пример #44
0
    def build(self):
        bin_path = os.path.join(self.build_dir, 'bin')

        if utils.file_exists(bin_path, bin_path):    
            utils.output("teem already built.  Skipping build step.")

        else:
            os.chdir(self.build_dir)
            ret = utils.make_command('teem.sln')

            if ret != 0:
                utils.error("Could not build teem.  Fix and try again.")
    def build(self):
        bin_path = os.path.join(self.build_dir,'src','multisurfaces','run-particle-system','optimize-particle-system.dir')

        if utils.file_exists(bin_path, bin_path):    
            utils.output("%s already built.  Skipping build step." % BASENAME)

        else:
            os.chdir(self.build_dir)
            ret = utils.make_command('Project.sln')

            if ret != 0:
                utils.error("Could not build %s.  Fix and try again." % BASENAME)
Пример #46
0
    def build(self):
        posix_file = os.path.join(self.build_dir,'bin','RelWithDebInfo','volume.o')
        nt_file    = os.path.join(self.build_dir,'bin','RelWithDebInfo','volume.lib')

        if utils.file_exists(posix_file, nt_file):    
            utils.output("%s already built.  Skipping build step." % BASENAME)

        else:
            os.chdir(self.build_dir)
            ret = utils.make_command('%s.sln' % BASENAME)

            if ret != 0:
                utils.error("Could not build %s.  Fix and try again." % BASENAME)
Пример #47
0
    def build(self):
        posix_file = os.path.join(self.build_dir, "bin/libvtkgdcmPython.so")
        nt_file = os.path.join(self.build_dir, "bin", config.BUILD_TARGET, "vtkgdcmPythonD.dll")

        if utils.file_exists(posix_file, nt_file):
            utils.output("GDCM already built.  Skipping build step.")

        else:
            os.chdir(self.build_dir)
            ret = utils.make_command("GDCM.sln")

            if ret != 0:
                utils.error("Could not build GDCM.  Fix and try again.")
Пример #48
0
    def build(self):
        nt_file = os.path.join(self.build_dir, 
                'vtkTeemInit.cxx')

        if utils.file_exists(nt_file, nt_file):    
            utils.output("vtkTeem already built.  Skipping build step.")

        else:
            os.chdir(self.build_dir)
            ret = utils.make_command('vtkTeem.sln')

            if ret != 0:
                utils.error("Could not build vtkTeem.  Fix and try againn.")
Пример #49
0
def bwa_align(fastq_path, reference_prefix, out_file, cores=1):
    edit_distance = MAX_EDIT_DISTANCE
    if file_exists(out_file):
        print ("%s has already been aligned, skipping." % (fastq_path))
        return out_file

    with file_transaction(out_file) as tx_out_file:

        cmd = ("bwa aln -n {edit_distance} -l 24 {reference_prefix} "
               "{fastq_path} -t {cores} | bwa samse {reference_prefix} - {fastq_path} "
               "> {tx_out_file}").format(**locals())
        subprocess.check_call(cmd, shell=True)
    return out_file
Пример #50
0
    def build(self):
        posix_file = os.path.join(self.build_dir,
            'bin/libvtkWidgetsPython.so')
        nt_file = os.path.join(self.build_dir, 'bin', config.BUILD_TARGET, 
                'vtkWidgetsPythonD.dll')

        if utils.file_exists(posix_file, nt_file):
            utils.output("VTK already built.  Skipping build step.")

        else:
            os.chdir(self.build_dir)
            ret = utils.make_command('VTK.sln')
            if ret != 0:
                utils.error("Error building VTK.  Fix and try again.")
Пример #51
0
def configure_deluge():
# sudo cp $HOME/src/raspi-config/deluge/logrotate.d_deluge /etc/logrotate.d/deluge
    with settings(warn_only=True):
        sudo("cp /home/pi/src/raspi-config/deluge/deluge.conf /etc/init/")
        sudo("cp /home/pi/src/raspi-config/deluge/deluge-webui.conf /etc/init/")
        sudo("mkdir -p /var/log/deluge && sudo chown -R pi:pi /var/log/deluge && sudo chmod -R 750 /var/log/deluge")
        sudo("cp /home/pi/src/raspi-config/deluge/logrotate.d_deluge /etc/logrotate.d/deluge")
        run("ln -sf /media/RaspiHD/torrent/completo/ /home/pi/runtime/")
        run("ln -sf /media/RaspiHD/torrent/download/ /home/pi/runtime/")
        run("ln -sf /media/RaspiHD/torrent/tv_shows.cache /home/pi/runtime/")
        sudo("start deluge")
        sudo("stop deluge")
        if file_exists('/media/RaspiHD/backup/backup.deluge.tar.gz'):
            run('python $HOME/src/raspi-config/scripts/backup.py restore /media/RaspiHD/backup/ deluge')
Пример #52
0
    def build(self):
        posix_file = os.path.join(self.build_dir, config.BUILD_TARGET,
            'libvtkErCorePython.so') #TODO: check whether this is the correct file to test on
        nt_file = os.path.join(self.build_dir, config.BUILD_TARGET, 
                'vtkErCorePythonD.dll')
        
        if utils.file_exists(posix_file, nt_file):
            utils.output("Template Workbench already built.  Skipping build step.")

        else:
            os.chdir(self.build_dir)
            ret = utils.make_command('ErGUI.sln')
            if ret != 0:
                utils.error("Error building Template Workbench. Fix and try again.")
Пример #53
0
def checker(request, path):
    if not file_exists(path, ad_path):
        return HttpResponseNotFound('<h1>Page not found</h1>')

    #checkers = ['now', 'true', 'rand', 'rand', 'false']
    checkers = ['now', 'true', 'rand', 'rand', 'rand']


    t = loader.get_template('checker.html')
    c = Context({
        'name': path,
        'checkers': ','.join(checkers),
    })
    return HttpResponse(t.render(c))
Пример #54
0
def star_align(fastq_path, reference_prefix, out_prefix, cores=1):
    max_best = MAX_BEST
    out_file = out_prefix + "Aligned.out.sam"
    if file_exists(out_file):
        print ("%s has already been aligned, skipping." % (fastq_path))
        return out_file

    cmd = ("STAR --genomeDir {reference_prefix} --readFilesIn {fastq_path} "
           "--runThreadN {cores} --outFileNamePrefix {out_prefix} "
           "--outFilterMultimapNmax {max_best} "
           "--outSAMattributes NH HI NM MD AS "
           "--outSAMstrandField intronMotif").format(**locals())
    subprocess.check_call(cmd, shell=True)
    return out_file
Пример #55
0
def remove(args):
    """ Runs the full removal process after ensuring the .desktop exists. """
    program = args["name"]

    if not utils.file_exists(DotDesktopModel.INSTALL_DIR+program+".desktop"):
        print program + ".desktop is not installed."
        sys.exit()

    output.line()
    
    _run_remove_desktop(program)
    _run_remove_icon(program)
    
    print "Bye!"
    output.line()
Пример #56
0
    def build(self):
        posix_file = os.path.join(
                self.build_dir, 'bin', 'cswig')
        nt_file = os.path.join(
                self.build_dir, 'bin', config.BUILD_TARGET,
                'cswig.exe')

        if utils.file_exists(posix_file, nt_file):
            utils.output("CableSwig already built.  Skipping build step.")

        else:
            os.chdir(self.build_dir)
            ret = utils.make_command('CableSwig.sln')
            if ret != 0:
                utils.error("Error building CableSwig.  Fix and try again.")
Пример #57
0
    def build(self):
        posix_file = os.path.join(self.build_dir, 
                'bin/libvtkdevideExternalPython.so')
        nt_file = os.path.join(self.build_dir, 'bin',
                config.BUILD_TARGET, 
                'vtkdevideExternalPython' + config.PYE_EXT)

        if utils.file_exists(posix_file, nt_file):    
            utils.output("vtkdevide already built.  Skipping build step.")

        else:
            os.chdir(self.build_dir)
            ret = utils.make_command('VTKDEVIDE.sln')
            if ret != 0:
                utils.error("Could not build vtkdevide.  Fix and try again.")
Пример #58
0
    def build(self):
        posix_file = os.path.join(self.build_dir, 
                'bin/libvtktudossGraphicsPython.so')
        nt_file = os.path.join(self.build_dir, 'bin',
                config.BUILD_TARGET, 'vtktudossGraphicsPythonD.dll')

        if utils.file_exists(posix_file, nt_file):    
            utils.output("vtktudoss already built.  Skipping build step.")

        else:
            os.chdir(self.build_dir)
            ret = utils.make_command('VTKTUDOSS.sln')

            if ret != 0:
                utils.error("Could not build vtktudoss.  Fix and try again.")
Пример #59
0
    def install(self):
        posix_file = os.path.join(self.inst_dir, 'bin/vtkpython')
        nt_file = os.path.join(self.inst_dir, 'bin', 'vtkpython.exe')

        if utils.file_exists(posix_file, nt_file):    
            utils.output("VTK already installed.  Skipping build step.")

        else:
            # python 2.5.2 setup.py complains that this does not exist
            # with VTK PV-3-2-1.  This is only on installations with
            # EasyInstall / Python Eggs, then the VTK setup.py uses
            # EasyInstall and not standard distutils.  gah!
            
            # just tested with VTK 5.8.0 and Python 2.7.2
            # it indeed installs VTK_PYTHON/VTK-5.8.0-py2.7.egg
            # but due to the site.py and easy-install.pth magic in there,
            # adding VTK_PYTHON to the PYTHONPATH still works. We can keep
            # pip, yay!
            if not os.path.exists(config.VTK_PYTHON):
                os.makedirs(config.VTK_PYTHON)

            os.chdir(self.build_dir)

            # we save, set and restore the PP env variable, else
            # stupid setuptools complains
            save_env = os.environ.get('PYTHONPATH', '')
            os.environ['PYTHONPATH'] = config.VTK_PYTHON
            ret = utils.make_command('VTK.sln', install=True)
            os.environ['PYTHONPATH'] = save_env

            if ret != 0:
                utils.error("Could not install VTK.  Fix and try again.")

            # now do some surgery on VTKConfig.cmake and
            # VTKLibraryDepends.cmake so builds of VTK-dependent libraries
            # with only the DRE to link with Just Work(tm)

            # on windows, we need to replace backslash with forward slash
            # as that's the style used by the config files. On *ix mostly
            # harmless
            idp = re.sub(r'\\','/', config.inst_dir)
            for fn in [os.path.join(config.VTK_DIR, 'VTKConfig.cmake'),
                    os.path.join(config.VTK_DIR, 'VTKLibraryDepends.cmake'),
                    os.path.join(config.VTK_DIR, 'VTKTargets-relwithdebinfo.cmake')]:
                if os.path.exists(fn):
                    utils.re_sub_filter_file(
                            [(idp,  '${VTK_INSTALL_PREFIX}/..')], 
                            fn)