Python django.conf.settings.BASE_DIR Examples

The following are 30 code examples for showing how to use django.conf.settings.BASE_DIR(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module django.conf.settings , or try the search function .

Example 1
Project: yang-explorer   Author: CiscoDevNet   File: schema.py    License: Apache License 2.0 6 votes vote down vote up
def validate_schema(user, name, version):
    if not version:
        fn = os.path.join(ServerSettings.yang_path(user), name + '.yang')
    else:
        fn = os.path.join(ServerSettings.yang_path(user), name + '@'+ version + '.yang')
    
    if os.path.exists(fn):
        return None 

    dirpath = os.path.join(settings.BASE_DIR, ServerSettings.yang_path(user))
    sfile = os.path.basename(fn.split('@')[0])
    if not sfile.endswith('.yang'): 
        sfile = sfile + '.yang'

    for file in os.listdir(dirpath):
        yfile = os.path.basename(file.split('@')[0])
        if not yfile.endswith('.yang'):
            yfile = yfile + '.yang'
        if sfile == yfile: 
            return '[out-of-sync]'
    return '[not-exist]' 
Example 2
Project: yang-explorer   Author: CiscoDevNet   File: admin.py    License: Apache License 2.0 6 votes vote down vote up
def dependencies_graph(username, modules=[]):
    depfile = os.path.join(ServerSettings.yang_path(username), 'dependencies.xml')
    if not os.path.exists(depfile):
        (rc, msg) = Compiler.compile_pyimport(username, None)
        if not rc:
            return rc, msg

    dgraph = DYGraph(depfile)
    g = dgraph.digraph([m.text.split('.yang')[0] for m in modules])
    if g is None:
        return (False, """Failed to generate dependency graph, please make sure that grapviz
python package is installed !!""")

    try:
        g.render(filename=os.path.join(settings.BASE_DIR, 'static', 'graph'))
    except:
        return (False, """Failed to render dependency graph, please make sure that grapviz
binaries (http://www.graphviz.org/Download.php) are installed on
the server !!""")

    return True, g.comment 
Example 3
Project: raveberry   Author: raveberry   File: youtube.py    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
def youtube_session() -> Iterator[requests.Session]:
    """This context opens a requests session and loads the youtube cookies file."""
    session = requests.session()
    try:
        with open(
            os.path.join(settings.BASE_DIR, "config/youtube_cookies.pickle"), "rb"
        ) as f:
            session.cookies.update(pickle.load(f))
    except FileNotFoundError:
        pass

    headers = {
        "User-Agent": youtube_dl.utils.random_user_agent(),
    }
    session.headers.update(headers)
    yield session

    with open(
        os.path.join(settings.BASE_DIR, "config/youtube_cookies.pickle"), "wb"
    ) as f:
        pickle.dump(session.cookies, f) 
Example 4
Project: raveberry   Author: raveberry   File: system.py    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
def enable_streaming(self, _request: WSGIRequest) -> HttpResponse:
        """Enable icecast streaming."""
        icecast_exists = False
        for line in subprocess.check_output(
            "systemctl list-unit-files --full --all".split(), universal_newlines=True
        ).splitlines():
            if "icecast2.service" in line:
                icecast_exists = True
                break

        if not icecast_exists:
            return HttpResponseBadRequest("Please install icecast2")

        subprocess.call(["sudo", "/usr/local/sbin/raveberry/enable_streaming"])
        config_file = os.path.join(settings.BASE_DIR, "setup/mopidy_icecast.conf")
        self.update_mopidy_config(config_file)
        return HttpResponse() 
Example 5
Project: raveberry   Author: raveberry   File: programs.py    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
def start(self) -> None:
        self.current_frame = [0 for _ in range(self.bars)]
        self.growing_frame = b""
        try:
            # delete old contents of the pipe
            os.remove(self.cava_fifo_path)
        except FileNotFoundError:
            # the file does not exist
            pass
        try:
            os.mkfifo(self.cava_fifo_path)
        except FileExistsError:
            # the file already exists
            logging.info("%s already exists while starting", self.cava_fifo_path)

        self.cava_process = subprocess.Popen(
            ["cava", "-p", os.path.join(settings.BASE_DIR, "config/cava.config")],
            cwd=settings.BASE_DIR,
        )
        # cava_fifo = open(cava_fifo_path, 'r')
        self.cava_fifo = os.open(self.cava_fifo_path, os.O_RDONLY | os.O_NONBLOCK) 
Example 6
Project: openvpn-admin   Author: alexsilva   File: openvpn.py    License: MIT License 6 votes vote down vote up
def handle(self, *args, **options):
        """"""
        ovpn = Ovpn.objects.filter(activated=True)
        if ovpn.exists():
            self._kill_old_process()
            ovpn = ovpn[0]
            print >> sys.stdout, "Config: {0.path}".format(ovpn.file)
            auth_filepath = os.path.join(settings.BASE_DIR, "vpn{0.vpn.pk}.auth.txt".format(ovpn))
            with open(auth_filepath, "w") as auth:
                auth.write(ovpn.vpn.username + '\n')
                auth.write(ovpn.vpn.password + '\n')
            # get file content
            with open(ovpn.file.path, "r") as vpn:
                vpn_file_content = vpn.readlines()
            # change file
            for index, line in enumerate(vpn_file_content):
                if re.match(self.vpn_param + '.*', line):
                    vpn_file_content[index] = "{0.vpn_param} {1:s}\n".format(self, auth_filepath)
                    break
            # write new data
            with open(ovpn.file.path, "w") as vpn:
                vpn.write(''.join(vpn_file_content))
            # vpn activate
            sh.openvpn(ovpn.file.path, _out=sys.stdout) 
Example 7
Project: don   Author: CiscoSystems   File: views.py    License: Apache License 2.0 6 votes vote down vote up
def analyze(request):
    # pwd = settings.BASE_DIR
    pwd = settings.ROOT_PATH
    JSON_FILE = pwd + '/don/ovs/don.json'

    params = {
        'error_file': pwd + '/don/templates/don/don.error.txt',
        'test:all': True,
        'test:ping': False,
        'test:ping_count': 1,
        'test:ovs': True,
        'test:report_file': pwd + '/don/templates/don/don.report.html',
    }
    print "params ====> ", params
    analyzer.analyze(JSON_FILE, params)
    # output = analyzer.analyze(JSON_FILE, params)
    # html = '<html><body>Output: %s</body></html>' % output
    # return HttpResponse(html)
    # return HttpResponseRedirect('/static/don.report.html')
    return render(request, "don/ovs/analyze.html")
    # return render_to_response('don/ovs/analyze.html') 
Example 8
Project: don   Author: CiscoSystems   File: views.py    License: Apache License 2.0 6 votes vote down vote up
def collect(request):
    macro = {'collect_status': 'Collection failed'}
    status = 0

    BASE_DIR = settings.ROOT_PATH
    # CUR_DIR = os.getcwd()
    os.chdir(BASE_DIR + '/don/ovs')
    cmd = 'sudo python collector.py'
    for line in run_command(cmd):
        if line.startswith('STATUS:') and line.find('Writing collected info') != -1:
            status = 1
            macro['collect_status'] = \
                "Collecton successful. Click visualize to display"
    # res = collector.main()
    os.chdir(BASE_DIR)
    if status:
        messages.success(request, macro['collect_status'])
    else:
        messages.error(request, macro['collect_status'])
    resp = HttpResponse(json.dumps(macro), content_type="application/json")
    return resp 
Example 9
Project: django-echarts   Author: kinegratii   File: _download.py    License: MIT License 6 votes vote down vote up
def handle(self, *args, **options):
        js_names = options['js_name']
        js_host = options.get('js_host')
        fake = options.get('fake', False)
        # Start handle
        fake_result = []
        for i, js_name in enumerate(js_names):
            remote_url = self.get_remote_url(settings, DJANGO_ECHARTS_SETTINGS, js_name, js_host)
            local_url = DJANGO_ECHARTS_SETTINGS.generate_local_url(js_name)
            local_path = settings.BASE_DIR + local_url.replace('/', os.sep)  # url => path
            fake_result.append((remote_url, local_path, local_url))
            if fake:
                self.stdout.write('[Info] Download Meta for [{}]'.format(js_name))
                self.stdout.write('        Remote Url: {}'.format(remote_url))
                self.stdout.write('        Local  Url: {}'.format(local_url))
                self.stdout.write('        Local Path: {}'.format(local_path))
            else:
                self.download_js_file(remote_url, local_path) 
Example 10
Project: mendelmd   Author: raonyguimaraes   File: update_files.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def download_files(self):
        print('Download Files')
        file_list = open('%s/data/files/all_files.txt' % (settings.BASE_DIR), 'w')
        s3credentials = S3Credential.objects.all()
        for s3credential in s3credentials:
            print(s3credential.name)
            for bucket_name in s3credential.buckets.splitlines():
                session = boto3.Session(
                    aws_access_key_id=s3credential.access_key,
                    aws_secret_access_key=s3credential.secret_key
                )
                s3 = session.resource('s3')
                bucket = s3.Bucket(bucket_name)
                print(bucket)
                for key in bucket.objects.all():
                    if key.size != 0:
                        file = [str(key.last_modified), str(key.size), bucket.name, key.key]
                        file_list.writelines('%s\n' % ('\t'.join(file)))
        self.stdout.write(self.style.SUCCESS('Successfully downloaded files!')) 
Example 11
Project: mendelmd   Author: raonyguimaraes   File: download_files.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def handle(self, *args, **options):
        print('Hello World Import Files')
        start_time = time.time()
        print('Download Files')
        command = 'mkdir -p {}/data/files/'.format(settings.BASE_DIR)
        run(command, shell=True)
        file_list = open('%s/data/files/all_files.txt' % (settings.BASE_DIR), 'w')
        s3credentials = S3Credential.objects.all()
        for s3credential in s3credentials:
            print(s3credential.name)
            for bucket_name in s3credential.buckets.splitlines():
                session = boto3.Session(
                    aws_access_key_id=s3credential.access_key,
                    aws_secret_access_key=s3credential.secret_key
                )
                s3 = session.resource('s3')
                bucket = s3.Bucket(bucket_name)
                print(bucket)
                for key in bucket.objects.all():
                    if key.size != 0:
                        file = [str(key.last_modified), str(key.size), bucket.name, key.key]
                        file_list.writelines('%s\n' % ('\t'.join(file)))
        self.stdout.write(self.style.SUCCESS('Successfully downloaded files!'))
        elapsed_time = time.time() - start_time
        print('Importing Files Took {}'.format(elapsed_time)) 
Example 12
Project: mendelmd   Author: raonyguimaraes   File: update_files.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def download_files(self):
        print('Download Files')
        file_list = open('%s/data/files/all_files.txt' % (settings.BASE_DIR), 'w')
        s3credentials = S3Credential.objects.all()
        for s3credential in s3credentials:
            print(s3credential.name)
            for bucket_name in s3credential.buckets.splitlines():
                session = boto3.Session(
                    aws_access_key_id=s3credential.access_key,
                    aws_secret_access_key=s3credential.secret_key
                )
                s3 = session.resource('s3')
                bucket = s3.Bucket(bucket_name)
                print(bucket)
                for key in bucket.objects.all():
                    if key.size != 0:
                        file = [str(key.last_modified), str(key.size), bucket.name, key.key]
                        file_list.writelines('%s\n' % ('\t'.join(file)))
        self.stdout.write(self.style.SUCCESS('Successfully downloaded files!')) 
Example 13
Project: mendelmd   Author: raonyguimaraes   File: download_files.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def handle(self, *args, **options):
        print('Hello World Import Files')
        start_time = time.time()
        print('Download Files')
        command = 'mkdir -p {}/data/files/'.format(settings.BASE_DIR)
        run(command, shell=True)
        file_list = open('%s/data/files/all_files.txt' % (settings.BASE_DIR), 'w')
        s3credentials = S3Credential.objects.all()
        for s3credential in s3credentials:
            print(s3credential.name)
            for bucket_name in s3credential.buckets.splitlines():
                session = boto3.Session(
                    aws_access_key_id=s3credential.access_key,
                    aws_secret_access_key=s3credential.secret_key
                )
                s3 = session.resource('s3')
                bucket = s3.Bucket(bucket_name)
                print(bucket)
                for key in bucket.objects.all():
                    if key.size != 0:
                        file = [str(key.last_modified), str(key.size), bucket.name, key.key]
                        file_list.writelines('%s\n' % ('\t'.join(file)))
        self.stdout.write(self.style.SUCCESS('Successfully downloaded files!'))
        elapsed_time = time.time() - start_time
        print('Importing Files Took {}'.format(elapsed_time)) 
Example 14
Project: koku   Author: project-koku   File: database.py    License: GNU Affero General Public License v3.0 6 votes vote down vote up
def config():
    """Database config."""
    service_name = ENVIRONMENT.get_value("DATABASE_SERVICE_NAME", default="").upper().replace("-", "_")
    if service_name:
        engine = engines.get(ENVIRONMENT.get_value("DATABASE_ENGINE"), engines["postgresql"])
    else:
        engine = engines["postgresql"]

    name = ENVIRONMENT.get_value("DATABASE_NAME", default="postgres")

    if not name and engine == engines["sqlite"]:
        name = os.path.join(settings.BASE_DIR, "db.sqlite3")

    db_config = {
        "ENGINE": engine,
        "NAME": name,
        "USER": ENVIRONMENT.get_value("DATABASE_USER", default="postgres"),
        "PASSWORD": ENVIRONMENT.get_value("DATABASE_PASSWORD", default="postgres"),
        "HOST": ENVIRONMENT.get_value(f"{service_name}_SERVICE_HOST", default="localhost"),
        "PORT": ENVIRONMENT.get_value(f"{service_name}_SERVICE_PORT", default=15432),
    }

    database_cert = ENVIRONMENT.get_value("DATABASE_SERVICE_CERT", default=None)
    return _cert_config(db_config, database_cert) 
Example 15
Project: kboard   Author: kboard   File: test_views.py    License: MIT License 6 votes vote down vote up
def test_can_modify_uploaded_file_with_edit_post(self):
        uploaded_file = SimpleUploadedFile(AttachmentModelTest.SAVED_TEST_FILE_NAME_1,
                                           open(AttachmentModelTest.UPLOAD_TEST_FILE_NAME, 'rb').read())
        Attachment.objects.create(post=self.default_post, attachment=uploaded_file)

        self.assertEqual(Attachment.objects.get(post=self.default_post).attachment.name,
                         AttachmentModelTest.SAVED_TEST_FILE_NAME_1)

        upload_file = open(os.path.join(settings.BASE_DIR, 'test_file/attachment_test_2.txt'))
        self.client.post(reverse('board:edit_post', args=[self.default_post.id]), {
            'title': 'some post title',
            'content': 'some post content',
            'attachment': upload_file,
        })

        self.assertEqual(Attachment.objects.get(post=self.default_post).attachment.name,
                         AttachmentModelTest.SAVED_TEST_FILE_NAME_2) 
Example 16
Project: kboard   Author: kboard   File: test_views.py    License: MIT License 6 votes vote down vote up
def test_record_edited_attachment_if_attachment_is_modified(self):
        uploaded_file = SimpleUploadedFile(AttachmentModelTest.SAVED_TEST_FILE_NAME_1,
                                           open(AttachmentModelTest.UPLOAD_TEST_FILE_NAME, 'rb').read())
        origin_attachment = Attachment.objects.create(post=self.default_post, attachment=uploaded_file)

        upload_file = open(os.path.join(settings.BASE_DIR, 'test_file/attachment_test_2.txt'))
        self.client.post(reverse('board:edit_post', args=[self.default_post.id]), {
            'title': 'NEW POST TITLE',
            'content': 'NEW POST CONTENT',
            'attachment': upload_file,
        })

        origin_attachment.refresh_from_db()
        new_attachment = Attachment.objects.get(post=self.default_post)
        edtied_post_history = EditedPostHistory.objects.get(post=self.default_post)

        self.assertEqual(origin_attachment.post, None)
        self.assertEqual(origin_attachment.editedPostHistory, edtied_post_history)
        self.assertEqual(new_attachment.post, self.default_post)
        self.assertEqual(new_attachment.editedPostHistory, None) 
Example 17
Project: fermentrack   Author: thorrak   File: clog.py    License: MIT License 6 votes vote down vote up
def get_filepath_to_log(device_type, logfile="", device_id=None):
    # get_filepath_to_log is being broken out so that we can use it in help/other templates to display which log file
    # is being loaded
    if device_type == "brewpi":
        try:
            device = BrewPiDevice.objects.get(id=device_id)
            log_filename = 'dev-{}-{}.log'.format(str(device.circus_parameter()).lower(), logfile)
        except:
            # Unable to load the device
            raise ValueError("No brewpi device with id {}".format(device_id))

    elif device_type == "spawner":
        log_filename = 'fermentrack-processmgr.log'
    elif device_type == "fermentrack":
        log_filename = 'fermentrack-stderr.log'
    elif device_type == "ispindel":
        log_filename = 'ispindel_raw_output.log'
    elif device_type == "upgrade":
        log_filename = 'upgrade.log'
    else:
        return None

    # Once we've determined the filename from logfile and device_type, let's open it up & read it in
    logfile_path = os.path.join(settings.BASE_DIR, 'log', log_filename)
    return logfile_path 
Example 18
Project: jd_analysis   Author: awolfly9   File: views.py    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
def randitem(request):
    data = {
        'status': 'failure',
        'guid': '0',
        'info': '',
    }
    try:
        is_rand = request.POST.get('rand')
        if is_rand == 'true':
            data['status'] = 'success'
            data['guid'] = str(uuid.uuid4())
            data['info'] = '成功接收数据,正在为您抓取并分析数据,精彩稍候呈现'

            cmd = 'cd {dir};python manage.py rand_item_analysis -a name={name} -a guid={guid}'. \
                format(dir = settings.BASE_DIR, name = 'jd', guid = data.get('guid'))
            subprocess.Popen(cmd, shell = True)
        else:
            data['info'] = '传入参数有误'
    except Exception, e:
        logging.error('rand item exception:%s' % e)
        data['info'] = '出现错误,错误原因:%s' % e 
Example 19
Project: WebMap   Author: SabyasachiRana   File: functions_nmap.py    License: GNU General Public License v3.0 6 votes vote down vote up
def nmap_newscan(request):
	if request.method == "POST":
		if(re.search('^[a-zA-Z0-9\_\-\.]+$', request.POST['filename']) and re.search('^[a-zA-Z0-9\-\.\:\=\s,]+$', request.POST['params']) and re.search('^[a-zA-Z0-9\-\.\:\/\s]+$', request.POST['target'])):
			res = {'p':request.POST}
			os.popen('nmap '+request.POST['params']+' --script='+settings.BASE_DIR+'/nmapreport/nmap/nse/ -oX /tmp/'+request.POST['filename']+'.active '+request.POST['target']+' > /dev/null 2>&1 && '+
			'sleep 10 && mv /tmp/'+request.POST['filename']+'.active /opt/xml/'+request.POST['filename']+' &')

			if request.POST['schedule'] == "true":
				schedobj = {'params':request.POST, 'lastrun':time.time(), 'number':0}
				filenamemd5 = hashlib.md5(str(request.POST['filename']).encode('utf-8')).hexdigest()
				writefile = settings.BASE_DIR+'/nmapreport/nmap/schedule/'+filenamemd5+'.json'
				file = open(writefile, "w")
				file.write(json.dumps(schedobj, indent=4))

			return HttpResponse(json.dumps(res, indent=4), content_type="application/json")
		else:
			res = {'error':'invalid syntax'}
			return HttpResponse(json.dumps(res, indent=4), content_type="application/json") 
Example 20
Project: tom_base   Author: TOMToolkit   File: tom_setup.py    License: GNU General Public License v3.0 6 votes vote down vote up
def create_project_dirs(self):
        self.status('Creating project directories... ')
        try:
            os.mkdir(os.path.join(BASE_DIR, 'data'))
        except FileExistsError:
            pass
        try:
            os.mkdir(os.path.join(BASE_DIR, 'templates'))
        except FileExistsError:
            pass
        try:
            os.mkdir(os.path.join(BASE_DIR, 'static'))
        except FileExistsError:
            pass
        # os.mknod requires superuser permissions on osx, so create a blank file instead
        try:
            open(os.path.join(BASE_DIR, 'static/.keep'), 'w').close()
        except FileExistsError:
            pass
        try:
            os.mkdir(os.path.join(BASE_DIR, 'tmp'))
        except FileExistsError:
            pass
        self.ok() 
Example 21
Project: Servo   Author: fpsw   File: selfupdate.py    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
def handle(self, *args, **options):
        mc = os.path.join(settings.BASE_DIR, 'manage.py')
        call(['git', 'pull', 'origin', 'master'])
        call([mc, 'migrate', '--no-initial-data'])
        call([mc, 'clearsessions']) 
Example 22
Project: yang-explorer   Author: CiscoDevNet   File: misc.py    License: Apache License 2.0 5 votes vote down vote up
def schema_path(session):
        """ Path to schema path """
        return os.path.join(settings.BASE_DIR, 'data', 'session', session) 
Example 23
Project: yang-explorer   Author: CiscoDevNet   File: misc.py    License: Apache License 2.0 5 votes vote down vote up
def annotation_path(user):
        """ Path to schema path """
        return os.path.join(settings.BASE_DIR, 'data', 'annotation') 
Example 24
Project: yang-explorer   Author: CiscoDevNet   File: yang.py    License: Apache License 2.0 5 votes vote down vote up
def compile_pyimport(username, session=None):
        """
        Compile yang model and return tuple (boolean, list-of-errors)
        """
        plugins = os.path.join(settings.BASE_DIR, 'explorer', 'plugins')
        if not os.path.exists(plugins):
            logging.error('CXML Plugin directory is missing .. !!')
            return False, None

        if subprocess.call(['which', 'pyang']) != 0:
            logging.error('Could not find pyang compiler, please install pyang .. !!')
            return False, None

        logging.debug('Rebuilding dependencies for user %s' % username)

        # build include path
        includes = [ServerSettings.yang_path(username)]
        if session is not None:
            session_dir = ServerSettings.session_path(session)
            if not os.path.exists(session_dir):
                logging.error('compile_pyimport: Session directory %s not found !!',  session_dir)
                return False, ["Session error !!"]
            includes.append(session_dir)
            depfile = os.path.join(session_dir, 'dependencies.xml')
        else:
            depfile = os.path.join(includes[0], 'dependencies.xml')

        target_yangs = []
        for yang_dir in includes:
            for _file in glob.glob(os.path.join(yang_dir, '*.yang')):
                target_yangs.append(_file)

        if not target_yangs:
            logging.debug('compile_pyimport: No yang file found !!')
            return True, ET.Element('messages')

        command = ['pyang', '-f', 'pyimport', '--plugindir', 'explorer/plugins', '-p']
        command += [':'.join(includes)]
        command += target_yangs

        return Compiler.invoke_compile(command, depfile) 
Example 25
Project: yang-explorer   Author: CiscoDevNet   File: models.py    License: Apache License 2.0 5 votes vote down vote up
def signal_delete_user(sender, **kwargs):
    logging.debug('Cleaning user workspace ..')
    username = kwargs.get('instance').username
    path = os.path.join(settings.BASE_DIR, 'data', 'users', username)
    if os.path.exists(path):
        shutil.rmtree(path) 
Example 26
Project: yang-explorer   Author: CiscoDevNet   File: bulkupload.py    License: Apache License 2.0 5 votes vote down vote up
def create_session(self):
        """ Create a fake session for upload process """

        # make sure base session folder exists in data dir
        sessiondir = os.path.join(settings.BASE_DIR, 'data', 'session')
        if not os.path.exists(sessiondir):
            os.mkdir(sessiondir)

        # create temp dir under session
        tempdir = tempfile.mkdtemp(dir=sessiondir)
        if not os.path.exists(tempdir):
            self.stdout.write("Failed: Failed to create temporary session !!")
            return None

        return tempdir 
Example 27
Project: django-migration-linter   Author: 3YOURMIND   File: test_data_migrations.py    License: Apache License 2.0 5 votes vote down vote up
def setUp(self, *args, **kwargs):
        self.test_project_path = os.path.dirname(settings.BASE_DIR)
        self.linter = MigrationLinter(
            self.test_project_path, include_apps=fixtures.DATA_MIGRATIONS,
        ) 
Example 28
Project: django-migration-linter   Author: 3YOURMIND   File: test_cache.py    License: Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.test_project_path = os.path.dirname(settings.BASE_DIR) 
Example 29
Project: django-migration-linter   Author: 3YOURMIND   File: test_migration_linter.py    License: Apache License 2.0 5 votes vote down vote up
def setUp(self, *args, **kwargs):
        self.test_project_path = os.path.dirname(settings.BASE_DIR)
        return super(BaseBackwardCompatibilityDetection, self).setUp(*args, **kwargs) 
Example 30
Project: raveberry   Author: raveberry   File: test_youtube.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def _poll_musiq_state(self, break_condition, timeout=1):
        """ Wrap the poll method of the super class to skip tests if Youtube doesn't play along."""
        try:
            return super()._poll_musiq_state(break_condition, timeout=timeout)
        except AssertionError:
            with open(os.path.join(settings.BASE_DIR, "logs/info.log")) as log:
                for line in log:
                    pass
                last_line = line
                if (
                    "ERROR: No video formats found" in last_line
                    or "ERROR: Unable to download webpage" in last_line
                ):
                    self.skipTest("Youtube provided no video formats")
            raise