当前位置: 首页>>代码示例>>Python>>正文


Python settings.BASE_DIR属性代码示例

本文整理汇总了Python中settings.BASE_DIR属性的典型用法代码示例。如果您正苦于以下问题:Python settings.BASE_DIR属性的具体用法?Python settings.BASE_DIR怎么用?Python settings.BASE_DIR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在settings的用法示例。


在下文中一共展示了settings.BASE_DIR属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: createUserConfig

# 需要导入模块: import settings [as 别名]
# 或者: from settings import BASE_DIR [as 别名]
def createUserConfig(MobSF_HOME):
    try:
        CONFIG_PATH = os.path.join(MobSF_HOME,'config.py')
        if isFileExists(CONFIG_PATH) == False:
            SAMPLE_CONF = os.path.join(settings.BASE_DIR,"MobSF/settings.py")
            with io.open(SAMPLE_CONF, mode='r', encoding="utf8", errors="ignore") as f:
                dat=f.readlines()
            CONFIG = list()
            add = False
            for line in dat:
                if "^CONFIG-START^" in line:
                    add = True
                if "^CONFIG-END^" in line:
                    break
                if add:
                    CONFIG.append(line.lstrip())
            CONFIG.pop(0)
            COMFIG_STR = ''.join(CONFIG)
            with io.open(CONFIG_PATH, mode='w', encoding="utf8", errors="ignore") as f:
                f.write(COMFIG_STR)
    except:
        PrintException("[ERROR] Cannot create config file") 
开发者ID:HackingLab,项目名称:MobileSF,代码行数:24,代码来源:utils.py

示例2: PrintException

# 需要导入模块: import settings [as 别名]
# 或者: from settings import BASE_DIR [as 别名]
def PrintException(msg,web=False):
    try:
        LOGPATH=settings.LOG_DIR
    except:
        LOGPATH = os.path.join(settings.BASE_DIR,"logs/")
    if not os.path.exists(LOGPATH):
        os.makedirs(LOGPATH)
    exc_type, exc_obj, tb = sys.exc_info()
    f = tb.tb_frame
    lineno = tb.tb_lineno
    filename = f.f_code.co_filename
    linecache.checkcache(filename)
    line = linecache.getline(filename, lineno, f.f_globals)
    ts = time.time()
    st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
    dat= '\n['+st+']\n'+msg+' ({0}, LINE {1} "{2}"): {3}'.format(filename, lineno, line.strip(), exc_obj)
    if platform.system()=="Windows":
        print dat
    else:
        if web:
            print Color.BOLD + Color.ORANGE + dat + Color.END
        else:
            print Color.BOLD + Color.RED + dat + Color.END
    with open(LOGPATH + 'MobSF.log','a') as f:
        f.write(dat) 
开发者ID:HackingLab,项目名称:MobileSF,代码行数:27,代码来源:utils.py

示例3: enumerate_sax_files

# 需要导入模块: import settings [as 别名]
# 或者: from settings import BASE_DIR [as 别名]
def enumerate_sax_files(patient_ids=None, filter_slice_type="sax"):
    for sub_dir in ["train", "validate", "test"]:
        for root, _, files in os.walk(settings.BASE_DIR + "\\data_kaggle\\" + sub_dir):
            # print root
            for file_name in files:
                if file_name.endswith(".dcm"):

                    parts = root.split('\\')
                    patient_id = parts[len(parts) - 3]
                    slice_type = parts[len(parts) - 1]
                    if filter_slice_type not in slice_type:
                        continue

                    if patient_ids is not None:
                        if patient_id not in patient_ids:
                            #print "skip " + patient_id
                            continue

                    file_path = root + "\\" + file_name
                    dicom_data = DicomWrapper(root + "\\", file_name)
                    yield dicom_data 
开发者ID:juliandewit,项目名称:kaggle_ndsb2,代码行数:23,代码来源:helpers.py

示例4: process_lidc_annotations

# 需要导入模块: import settings [as 别名]
# 或者: from settings import BASE_DIR [as 别名]
def process_lidc_annotations(only_patient=None, agreement_threshold=0):
    # lines.append(",".join())
    file_no = 0
    pos_count = 0
    neg_count = 0
    all_lines = []
    for anno_dir in [d for d in glob.glob("resources/luna16_annotations/*") if os.path.isdir(d)]:
        xml_paths = glob.glob(anno_dir + "/*.xml")
        for xml_path in xml_paths:
            print(file_no, ": ",  xml_path)
            pos, neg, extended = load_lidc_xml(xml_path=xml_path, only_patient=only_patient, agreement_threshold=agreement_threshold)
            if pos is not None:
                pos_count += len(pos)
                neg_count += len(neg)
                print("Pos: ", pos_count, " Neg: ", neg_count)
                file_no += 1
                all_lines += extended
            # if file_no > 10:
            #     break

            # extended_line = [nodule_id, x_center_perc, y_center_perc, z_center_perc, diameter_perc, malignacy, sphericiy, margin, spiculation, texture, calcification, internal_structure, lobulation, subtlety ]
    df_annos = pandas.DataFrame(all_lines, columns=["patient_id", "anno_index", "coord_x", "coord_y", "coord_z", "diameter", "malscore", "sphericiy", "margin", "spiculation", "texture", "calcification", "internal_structure", "lobulation", "subtlety"])
    df_annos.to_csv(settings.BASE_DIR + "lidc_annotations.csv", index=False) 
开发者ID:juliandewit,项目名称:kaggle_ndsb2017,代码行数:25,代码来源:step1_preprocess_luna16.py

示例5: _update_pedigree_image

# 需要导入模块: import settings [as 别名]
# 或者: from settings import BASE_DIR [as 别名]
def _update_pedigree_image(family, project_guid=None):
    """Uses HaploPainter to (re)generate the pedigree image for the given family.

    Args:
         family (object): seqr Family model.
    """

    individual_records = _get_parsed_individuals(family, project_guid)
    if not individual_records:
        return

    # run HaploPainter to generate the pedigree image
    png_file_path = os.path.join(tempfile.gettempdir(), "pedigree_image_%s.png" % _random_string(10))
    family_id = family.family_id
    with tempfile.NamedTemporaryFile('w', suffix=".fam", delete=True) as fam_file:

        # columns: family, individual id, paternal id, maternal id, sex, affected
        for i in individual_records.values():
            row = [family_id] + [i[key] for key in ['individualId', 'paternalId', 'maternalId', 'sex', 'affected']]
            fam_file.write("\t".join(row))
            fam_file.write("\n")
        fam_file.flush()

        fam_file_path = fam_file.name
        haplopainter_command = "perl " + os.path.join(BASE_DIR, "seqr/management/commands/HaploPainter1.043.pl")
        haplopainter_command += " -b -outformat png -pedfile {fam_file_path} -family {family_id} -outfile {png_file_path}".format(
            fam_file_path=fam_file_path, family_id=family_id, png_file_path=png_file_path)
        os.system(haplopainter_command)

    if not os.path.isfile(png_file_path):
        logger.error("Failed to generated pedigree image for family: %s" % family_id)
        family.pedigree_image = None
        family.save()
        return

    _save_pedigree_image_file(family, png_file_path)

    os.remove(png_file_path) 
开发者ID:macarthur-lab,项目名称:seqr,代码行数:40,代码来源:pedigree_image_utils.py

示例6: getMobSFHome

# 需要导入模块: import settings [as 别名]
# 或者: from settings import BASE_DIR [as 别名]
def getMobSFHome(useHOME):
    try:
        MobSF_HOME = ""
        if useHOME:
            MobSF_HOME = os.path.join(os.path.expanduser('~'),".MobSF")
            #MobSF Home Directory
            if not os.path.exists(MobSF_HOME):
                os.makedirs(MobSF_HOME)
            createUserConfig(MobSF_HOME)
        else:
            MobSF_HOME = settings.BASE_DIR
        #Logs Directory
        LOG_DIR=os.path.join(MobSF_HOME, 'logs/')
        if not os.path.exists(LOG_DIR):
            os.makedirs(LOG_DIR)
        #Certs Directory
        CERT_DIR=os.path.join(LOG_DIR, 'certs/')
        if not os.path.exists(CERT_DIR):
            os.makedirs(CERT_DIR)
        #Download Directory
        DWD_DIR=os.path.join(MobSF_HOME, 'downloads/')
        if not os.path.exists(DWD_DIR):
            os.makedirs(DWD_DIR)
        #Screenshot Directory
        SCREEN_DIR = os.path.join(DWD_DIR, 'screen/')
        if not os.path.exists(SCREEN_DIR):
            os.makedirs(SCREEN_DIR)
        #Upload Directory
        UPLD_DIR=os.path.join(MobSF_HOME, 'uploads/')
        if not os.path.exists(UPLD_DIR):
            os.makedirs(UPLD_DIR)
        return MobSF_HOME
    except:
        PrintException("[ERROR] Creating MobSF Home Directory") 
开发者ID:HackingLab,项目名称:MobileSF,代码行数:36,代码来源:utils.py

示例7: Migrate

# 需要导入模块: import settings [as 别名]
# 或者: from settings import BASE_DIR [as 别名]
def Migrate(BASE_DIR):
    try:
        manage = os.path.join(BASE_DIR,"manage.py")
        args = ["python", manage, "migrate"]
        subprocess.call(args)
    except:
        PrintException("[ERROR] Cannot Migrate") 
开发者ID:HackingLab,项目名称:MobileSF,代码行数:9,代码来源:utils.py

示例8: on_message

# 需要导入模块: import settings [as 别名]
# 或者: from settings import BASE_DIR [as 别名]
def on_message(self, message):
        print('get_msg--->',message)
        #第一次进来先读取所有
        task_id = message
        try:
            out_file = '%s/logs/%s.log'%(BASE_DIR,task_id)
            check_exit = os.path.exists(out_file)
            if not check_exit:
                open(out_file,'a').close()
            stdout_file = open(out_file)
            stdout_file.seek(os.path.getsize(out_file))
            if os.path.getsize(out_file) > 10240000:
                self.write_message('file is too large!')
            else:
                with open(out_file,'r') as f:
                    for line in f.readlines():
                        self.write_message(line)
            if task_id in LISTENERS:
                LISTENERS[task_id]['ele'].append(self)
            else:
                LISTENERS[task_id] = {
                    'ele':[self],
                    'stdout_file': stdout_file
                }
            self.task_id = task_id
        except Exception as e:
            self.write_message(str(e)) 
开发者ID:yangmv,项目名称:k8sMG,代码行数:29,代码来源:index_handler.py

示例9: setUp

# 需要导入模块: import settings [as 别名]
# 或者: from settings import BASE_DIR [as 别名]
def setUp(self):
    # TODO(nworden): see if there's a way to avoid this. You'd think
    # settings.BASE_DIR would be useful here but I can't figure out how to make
    # it work for prod, local servers, and tests without overriding the value in
    # tests.
    # The Django test client doesn't actually run a whole server, which is
    # really nice because it's much faster, but it does seem to mess with the
    # template loader, I guess because it's not running from where it normally
    # would (in the app directory).
    settings.TEMPLATES[0]['DIRS'] = ['app/resources']
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
    django.setup()
    setup_test_environment()
    self.client = Client() 
开发者ID:google,项目名称:personfinder,代码行数:16,代码来源:test_controller.py

示例10: predict_patients

# 需要导入模块: import settings [as 别名]
# 或者: from settings import BASE_DIR [as 别名]
def predict_patients(patients_dir, model_path, holdout, patient_predictions, model_type):
    model = get_unet(0.001)
    model.load_weights(model_path)
    for item_name in os.listdir(patients_dir):
        if not os.path.isdir(patients_dir + item_name):
            continue
        patient_id = item_name

        if holdout >= 0:
            patient_fold = helpers.get_patient_fold(patient_id, submission_set_neg=True)
            if patient_fold < 0:
                if holdout != 0:
                    continue
            else:
                patient_fold %= 3
                if patient_fold != holdout:
                    continue

        # if "100953483028192176989979435275" not in patient_id:
        #     continue
        print(patient_id)
        patient_dir = patients_dir + patient_id + "/"
        mass = 0
        img_type = "_i" if model_type == "masses" else "_c"
        slices = glob.glob(patient_dir + "*" + img_type + ".png")
        if model_type == "emphysema":
            slices = slices[int(len(slices) / 2):]
        for img_path in slices:
            src_img = cv2.imread(img_path, cv2.IMREAD_GRAYSCALE)
            src_img = cv2.resize(src_img, dsize=(settings.SEGMENTER_IMG_SIZE, settings.SEGMENTER_IMG_SIZE))
            src_img = prepare_image_for_net(src_img)
            p = model.predict(src_img, batch_size=1)
            p[p < 0.5] = 0
            mass += p.sum()
            p = p[0, :, :, 0] * 255
            # cv2.imwrite(img_path.replace("_i.png", "_mass.png"), p)
            src_img = src_img.reshape((settings.SEGMENTER_IMG_SIZE, settings.SEGMENTER_IMG_SIZE))
            src_img *= 255
            # src_img = cv2.cvtColor(src_img.astype(numpy.uint8), cv2.COLOR_GRAY2BGR)
            # p = cv2.cvtColor(p.astype(numpy.uint8), cv2.COLOR_GRAY2BGRA)
            src_img = cv2.addWeighted(p.astype(numpy.uint8), 0.2, src_img.astype(numpy.uint8), 1 - 0.2, 0)
            cv2.imwrite(img_path.replace(img_type + ".png", "_" + model_type + "o.png"), src_img)

        if mass > 1:
            print(model_type + ": ", mass)
        patient_predictions.append((patient_id, mass))
        df = pandas.DataFrame(patient_predictions, columns=["patient_id", "prediction"])
        df.to_csv(settings.BASE_DIR + model_type + "_predictions.csv", index=False) 
开发者ID:juliandewit,项目名称:kaggle_ndsb2017,代码行数:50,代码来源:step2_train_mass_segmenter.py


注:本文中的settings.BASE_DIR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。