示例#1
0
文件: items.py 项目: phonkee/easyfab
class SymlinkItem(BaseItem):
    src = None
    destination = None

    def __init__(self, src, destination):
        self.src = Path(src)
        self.destination = Path(destination)

    def run(self, context):
        if not self.src.isabsolute():
            self.src = Path(Path(context['target_dir']), self.src)

        if self.destination.isabsolute():
            destination = Path(context['package_root'], strip_root(self.destination))
        else:
            destination = Path(context['package_project_dir'], self.destination)

        parent_dir = destination.parent
        if not parent_dir.exists():
            parent_dir.mkdir(parents=True, mode=0777)

        command = 'ln -s %(src)s %(destination)s' % {
            'src': self.src,
            'destination': destination
        }
        fabric.api.local(command, capture=True)
示例#2
0
def load_inv_namespace(root_dir):
    """
    Execute the :xfile:`tasks.py` file of this project and return its
    `ns`.
    """
    # self._tasks_loaded = True
    
    tasks_file = root_dir.child('tasks.py')
    if not tasks_file.exists():
        return None
        # raise Exception("No tasks.py file in {}".format(root_dir))
        # return

    # print("20180428 load tasks.py from {}".format(root_dir))
    # http://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path
    # http://stackoverflow.com/questions/19009932/import-arbitrary-python-source-file-python-3-3
    # fqname = 'atelier.prj_%s' % self.index
    cwd = Path().resolve()
    root_dir.chdir()
    m = dict()
    m["__file__"] = str(tasks_file)
    with open(tasks_file) as f:
        exec(f.read(), m)
    cwd.chdir()
    return m['ns']
示例#3
0
def sort_episode(series_name, episode, torrent_path):
    # Ensure the series directory exists
    series_dir = Path(SERIES_DIR, series_name)
    series_dir.mkdir(True)

    if torrent_path.isdir():
        files = [torrent_path.listdir('*.' + ext) for ext in VIDEO_FILES]
        files = [f for sublist in files for f in sublist]
        files = remove_samples(files)
        logging.debug('List of files: {}'.format(files))

        if len(files) == 0:
            logging.critical('No video file found in series directory!')
            sys.exit(1)
        src_file = files[0]
        dst_file = Path(series_dir,
            series_name + ' - ' + episode + files[0].ext)
    else:
        if torrent_path.ext.replace('.', '') not in VIDEO_FILES:
            logging.warning('Unknown video file extention: {}'.format(
                torrent_path.ext))
        src_file = torrent_path
        dst_file = Path(series_dir, series_name + ' - ' + episode + \
            torrent_path.ext)

    logging.info('Copying single file to destination: {}'.format(
            dst_file))
    copy_file(src_file, dst_file)
示例#4
0
文件: items.py 项目: phonkee/easyfab
    def run(self, context):
        if not self.directory_name.isabsolute():
            directory = Path(Path(context['package_project_dir']), self.directory_name)
        else:
            directory = Path(context['package_root'], Path(strip_root(self.directory_name)))

        directory.mkdir(parents=True, mode=self.mode)
示例#5
0
def sphinx_build(builder, docs_dir,
                 cmdline_args=[], language=None, build_dir_cmd=None):
    args = ['sphinx-build', '-b', builder]
    args += cmdline_args
    # ~ args += ['-a'] # all files, not only outdated
    # ~ args += ['-P'] # no postmortem
    # ~ args += ['-Q'] # no output
    # build_dir = docs_dir.child(env.build_dir_name)
    build_dir = Path(env.build_dir_name)
    if language is not None:
        args += ['-D', 'language=' + language]
        # needed in select_lang.html template
        args += ['-A', 'language=' + language]
        if language != env.languages[0]:
            build_dir = build_dir.child(language)
            #~ print 20130726, build_dir
    if env.tolerate_sphinx_warnings:
        args += ['-w', 'warnings_%s.txt' % builder]
    else:
        args += ['-W']  # consider warnings as errors
        # args += ['-vvv']  # increase verbosity
    #~ args += ['-w'+Path(env.root_dir,'sphinx_doctest_warnings.txt')]
    args += ['.', build_dir]
    cmd = ' '.join(args)
    with lcd(docs_dir):
        local(cmd)
    if build_dir_cmd is not None:
        with lcd(build_dir):
            local(build_dir_cmd)
示例#6
0
def setup_babel_userdocs(babelcmd):
    """Create userdocs .po files if necessary."""
    userdocs = env.root_dir.child('userdocs')
    if not userdocs.isdir():
        return
    locale_dir = userdocs.child('translations')
    for domain in locale_dir.listdir('*.pot', names_only=True):
        domain = domain[:-4]
        for loc in env.languages:
            if loc != env.languages[0]:
                po_file = Path(locale_dir, loc, 'LC_MESSAGES', '%s.po' %
                               domain)
                mo_file = Path(locale_dir, loc, 'LC_MESSAGES', '%s.mo' %
                               domain)
                pot_file = Path(locale_dir, '%s.pot' % domain)
                if babelcmd == 'init_catalog' and po_file.exists():
                    print("Skip %s because file exists." % po_file)
                #~ elif babelcmd == 'compile_catalog' and not mo_file.needs_update(po_file):
                    #~ print "Skip %s because newer than .po" % mo_file
                else:
                    args = ["python", "setup.py"]
                    args += [babelcmd]
                    args += ["-l", loc]
                    args += ["--domain", domain]
                    args += ["-d", locale_dir]
                    #~ args += [ "-o" , po_file ]
                    #~ if babelcmd == 'init_catalog':
                    if babelcmd == 'compile_catalog':
                        args += ["-i", po_file]
                    else:
                        args += ["-i", pot_file]
                    cmd = ' '.join(args)
                    #~ must_confirm(cmd)
                    local(cmd)
示例#7
0
def download_qualities(force=False, i_have_enough_space=False, keep=False):
    url = 'https://ndownloader.figshare.com/files/6059502'
    bz2 = Path(DATA_DIR, 'article_qualities.tsv.bz2')
    tsv = Path(DATA_DIR, 'article_qualities.tsv')

    # Try to prevent accidentally downloading too big a file.
    if not i_have_enough_space:
        try:
            gb_available = int(run("df -g . | awk '/\//{ print $4 }'").stdout)
            if gb_available < 100:
                raise NotEnoughGBAvailable
        except:
            raise NotEnoughGBAvailable
        else:
            logger.info('Rest easy, you have enough space.')
    else:
        logger.info('Skipping space check. Good luck soldier!')

    if SQLITE_PATH.exists() and not force:
        raise DBAlreadyExists

    logger.info('Downloading and decompressing.')
    run('wget {url} > {bz2} && bunzip2 {bz2}'.format(url=url, bz2=bz2))

    logger.info('Importing into sqlite.')
    conn = connect_to_sqlite_db()
    for chunk in pandas.read_table(tsv, chunksize=100000):
        chunk.to_sql('qualities', conn, if_exists='append', index=False)
    conn.close()

    if not keep:
        tsv.remove()
示例#8
0
def builder_inited(app):
    """Define certain settings
    """
    mydir = Path(__file__).parent.child('static').absolute()
    app.config.html_static_path.append(mydir)
    app.config.html_logo = mydir.child('logo_web3.png')
    app.config.html_favicon = mydir.child('favicon.ico')
示例#9
0
def add_deployment(directory, name, templates_dir='templates', deployment_dir='deployment', mode=0777):
    """ Adds new deployment if not exists
    """
    context = {
        'datetime': datetime.datetime.now(),
        'name': name,
        'project_name': get_project_name(directory)
    }

    dd, df = get_deployment_info(directory, name)

    if df.exists():
        raise ExistingDeploymentError()

    # create deployments directory
    df.parent.mkdir(parents=True, mode=mode)

    # write deployment file
    df.write_file(
        get_rendered_template('deployment.py', context)
    )
    top_td = Path(__file__).parent.child(templates_dir)
    td = top_td.child(deployment_dir)
    for tf in td.walk():
        if tf.isdir():
            continue
        partitioned = tf.partition(td)
        target = Path(dd, Path(partitioned[2][1:]))
        target_dir = target.parent
        if not target_dir.exists():
            target_dir.mkdir(parents=True, mode=mode)
        tmp = tf.partition(top_td)[2][1:]
        rendered = get_rendered_template(tmp, context)
        target.write_file(rendered)
示例#10
0
def boostrap_nltk_data():
    nltk.data.path.append('./data/')
    nltkdata_exists = Path('./data/tokenizers/punkt/english.pickle')

    if not nltkdata_exists.exists():
        logging.info("Downloading NLTK Data")
        nltk.download('punkt', './data')
示例#11
0
    def run(self, username=None, pubkey=None, as_root=False):
        if as_root:
            remote_user = '******'
            execute = run
        else:
            remote_user = env.local_user
            execute = sudo

        with settings(user=remote_user):
            keyfile = Path(pubkey or Path('~', '.ssh', 'id_rsa.pub')).expand()

            if not keyfile.exists():
                abort('Public key file does not exist: %s' % keyfile)

            with open(keyfile, 'r') as f:
                pubkey = f.read(65535)

            username = username or prompt('Username: '******'s password: "******"%s\", \"password\")\'' % (password),
                             capture=True)

            for command in self.commands:
                execute(command.format(**locals()))
示例#12
0
 def test_dump2py(self):
     for prj in ["lino_book/projects/belref"]:
         p = Path(prj)
         tmp = p.child('tmp').absolute()
         tmp.rmtree()
         self.run_django_admin_command_cd(p, 'dump2py', tmp)
         self.assertEqual(tmp.child('restore.py').exists(), True)
示例#13
0
    def set_up_and_import_file(self):
        temp_dir = Path(tempfile.mkdtemp())
        temp_file = Path(temp_dir, 'test.csv')
        with open(temp_file, 'a') as f:
            header = ''
            header_fields = [
                'route',
                'account_number',
                'house_number',
                'pre_direction',
                'street',
                'street_type',
                'post_direction',
                'unit',
                'city_state_zip'
            ]
            
            for x, field in enumerate(header_fields):
                if x + 1 == len(header_fields):
                    header = header + field + '\n'
                else:
                    header = header + field + ','

            f.write(header)
            f.write('123,123,123,S,TEST,RD,S,#5B,"TEST, FL 32174"')

        mommy.make(
            'route_update.Directional', direction='South', abbreviation='S'
        )
        mommy.make('route_update.StreetType', name='Road', abbreviation='RD')
        mommy.make('route_update.State', name='Florida', abbreviation='FL')

        Location.create_active_locations_from_file(temp_file)

        temp_dir.rmtree()
示例#14
0
    def handle(self, *args, **options):

        from ....media.models import MediaFile
        from ...models import Transcript

        if len(args) != 1:
            raise CommandError('Provide media URL.')

        (url,) = args

        local_path = Path(url)
        if local_path.exists():
            url = 'file://{}'.format(local_path.absolute())

        media_file = MediaFile.objects.create(
            data_url=url,
        )
        if options['verbosity']:
            self.stdout.write('Created media file: {}'.format(media_file))

        transcript = Transcript.objects.create(
            name=url,
        )
        if options['verbosity']:
            self.stdout.write('Created transcript: {}'.format(transcript))
示例#15
0
文件: items.py 项目: phonkee/easyfab
class CopyItem(BaseItem):
    src = None
    destination = None
    only_content = None
    recursive = None

    def __init__(self, src, destination, only_content=False, recursive=False, follow_symlinks=True):
        self.follow_symlinks = follow_symlinks
        self.src = Path(src)
        self.destination = Path(destination)
        self.only_content = only_content
        self.recursive = recursive

    def run(self, context):
        if not self.src.isabsolute():
            self.src = Path(Path(context['project_dir']), self.src)
        if not self.destination.isabsolute():
            self.destination = Path(Path(context['package_project_dir']), self.destination)

        switches = []

        if self.recursive:
            switches.append("-R")

        if self.follow_symlinks:
            switches.append("-L")

        command = 'cp %(switches)s %(src)s %(destination)s' % {
            'switches': ' '.join(switches),
            'src': self.src,
            'destination': self.destination,
        }

        fabric.api.local(command, capture=True)
def get_closest_uid(path):
	path = Path(path)
	while not path.isdir():
		path = path.ancestor(1)
		if path == '/':
			return False
	return path.stat().st_uid
示例#17
0
文件: setup.py 项目: loogica/envkit
def superuser(pubkey=None, username=None):
    """
    fab env superuser
    """
    env.user = '******'

    keyfile = Path(pubkey or Path('~', '.ssh', 'id_rsa.pub')).expand()

    if not keyfile.exists():
        abort('Public key file does not exist: %s' % keyfile)

    username = username or prompt('Username: '******'Password: '******'perl -e \'print crypt(\"%s\", \"password\")\'' % (password),
                     capture=True)

    with open(keyfile, 'r') as f:
        pubkey = f.read(65535)

    commands = (
        'useradd -m -s /bin/bash -p {password} {username}',
        'mkdir ~{username}/.ssh -m 700',
        'echo "{pubkey}" >> ~{username}/.ssh/authorized_keys',
        'chmod 644 ~{username}/.ssh/authorized_keys',
        'chown -R {username}:{username} ~{username}/.ssh',
        'usermod -a -G sudo {username}',
    )

    for command in commands:
        run(command.format(**locals()))
示例#18
0
def environment(**options):
    queryfinder = QueryFinder()

    searchpath =[]
    staticdirs = []

    sites = settings.SHEER_SITES
    for site in sites:
        site_path = Path(site)
        searchpath.append(site_path)
        searchpath.append(site_path.child('_includes'))
        searchpath.append(site_path.child('_layouts'))
        staticdirs.append(site_path.child('static'))

    options['loader'].searchpath += searchpath
    settings.STATICFILES_DIRS = staticdirs

    env = SheerlikeEnvironment(**options)
    env.globals.update({
        'static': staticfiles_storage.url,
        'url_for':url_for,
        'url': reverse,
        'queries': queryfinder,
        'more_like_this': more_like_this,
        'get_document': get_document,
        'selected_filters_for_field': selected_filters_for_field,
        'is_filter_selected': is_filter_selected,
    })
    env.filters.update({
        'date':date_filter
    })
    return env
示例#19
0
def enviar_email_con_cupon(modeladmin, request, queryset):
    leads_incorrectos = 0
    leads_correctos = 0
    for lead in queryset:
        if lead.enviado_en_csv is True and lead.enviado_cupon is False and lead.colectivo_validado is True:
            for fichero in os.listdir(settings.COUPONS_ROOT):
                if fnmatch.fnmatch(fichero, str(lead.id)+'_*.pdf'):
                    cupon_fichero = Path(settings.COUPONS_ROOT, fichero)
                    if cupon_fichero.exists():
                        codigo = fichero.split("_")[1].split(".")[0]
                        url_cupon = settings.BASE_URL+'/static/coupons/'+fichero
                        mail = EmailMultiAlternatives(
                            subject="Mi cupón de 10€ de Juguetes Blancos",
                            body='Descarga tu cupon aqui: '+url_cupon+' </p>',
                            from_email="Rocio, JueguetesBlancos <*****@*****.**>",
                            to=[lead.email]
                        )
                        mail.attach_alternative(render_to_string('leads/email_cupon.html', {'lead': lead, 'url_cupon': url_cupon}), "text/html")
                        mail.send()
                        lead.enviado_cupon = True
                        lead.codigo_cupon = codigo
                        lead.save()
                        leads_correctos = leads_correctos+1
        else:
            leads_incorrectos = leads_incorrectos+1
    messages.success(request, str(leads_correctos)+' Email/s enviado Correctamente')
    messages.error(request, str(leads_incorrectos)+' Leads no cumplian las condiciones.')
示例#20
0
def activate_env():
    """ Activates the virtual environment for this project."""

    error_msg = None

    try:
        virtualenv_dir = Path(os.environ['WORKON_HOME'])
    except KeyError:
        error_msg = "Error: 'WORKON_HOME' is not set."

    if error_msg:
        color_init()
        sys.stderr.write(Fore.RED + Style.BRIGHT + error_msg + "\n")
        sys.exit(1)

    filepath = Path(__file__).absolute()
    site_dir = filepath.ancestor(4).components()[-1]
    repo_dir = filepath.ancestor(3).components()[-1]

    # Add the app's directory to the PYTHONPATH
    sys.path.append(filepath.ancestor(2))
    sys.path.append(filepath.ancestor(1))

    # Set manually in environment
    #os.environ['DJANGO_SETTINGS_MODULE'] = 'settings.production'

    if os.environ['DJANGO_SETTINGS_MODULE'] == 'settings.production':
        bin_parent = site_dir
    else:
        bin_parent = repo_dir

    # Activate the virtual env
    activate_env = virtualenv_dir.child(bin_parent, "bin", "activate_this.py")
    execfile(activate_env, dict(__file__=activate_env))
示例#21
0
文件: base.py 项目: phonkee/easyfab
 def __init__(self, deployment, project_dir, deployment_dir):
     self.deployment = deployment
     self.project_dir = Path(project_dir)
     self.deployment_dir = Path(deployment_dir)
     self.packages_dir = self.deployment_dir.child(".packages")
     self.target_dir = Path(self.target_dir)
     self.deployment_files_dir = deployment_dir.child(deployment)
示例#22
0
文件: utils.py 项目: phonkee/easyfab
def process_directory(directory, context, variable_start_string='{<',
                      variable_end_string='>}', extensions=None,
                      filter=FILES_NO_LINKS):
    directory = Path(directory)

    for f in directory.walk(filter=filter):
        if extensions:
            if f.ext not in extensions:
                continue

        components = f.components()
        td, tf = Path(*components[:-1]), components[-1]

        jinja_env = Environment(loader=FileSystemLoader(str(td)),
                                variable_start_string=variable_start_string,
                                variable_end_string=variable_end_string,
                                block_start_string='{<%',
                                block_end_string='%>}',
                                comment_start_string='{<#',
                                comment_end_string='#>}',
                                )
        try:
            rendered = jinja_env.get_template(str(tf)).render(**context)
        except Exception, e:
            print "Cannot process file %s on line %s" % (
                e.filename,
                e.lineno
            )
            continue
        f.write_file(rendered.encode('utf-8'))
示例#23
0
def release():
    """Assemble a release dist package."""
    # create the dist directory 
    with quiet():
        local('rm -rf {}'.format(env.paths['dist']))
        local('mkdir -p {}'.format(env.paths['dist']))
        # find compiled packages
        for (dirpath, dirnames, filenames) in os.walk(env.paths['compiled']):
            files = []
            filename = []
            for path in glob.glob(Path(dirpath).child('*.u')):
                path = Path(path)
                files.append(path)
                # filename has not yet been assembled
                if not filename:
                    # get path of a compile package relative to the directory
                    relpath = Path(os.path.relpath(path, start=env.paths['compiled']))
                    if relpath:
                        # first two components of the assembled dist package name
                        # are the original swat package name and its version..
                        filename = [env.paths['here'].name, env.dist['version']]
                        for component in relpath.components()[1:-1]:
                            # also include names of directories the components
                            # of the relative path
                            filename.append(component.lower())
                        filename.extend(['tar', 'gz'])
            if not files:
                continue
            # tar the following files
            files.extend(env.dist['extra'])
            with lcd(env.paths['dist']):
                local(r'tar -czf "{}" {} '.format(
                    '.'.join(filename),
                    ' '.join(['-C "{0.parent}" "{0.name}"'.format(f) for f in files])
                ))
示例#24
0
    def __init__(self, release_search_dir, tmp_dir, unpack_dir,
                 no_remove=False):
        self.release_search_dir = Path(release_search_dir)
        self.release_search_dir_abs = self.release_search_dir.absolute()
        self.tmp_dir = Path(tmp_dir)
        self.unpack_dir = Path(unpack_dir)
        self.no_remove = no_remove

        if not self.release_search_dir_abs.exists():
            raise ReleaseUnpackerError(
                'Release search dir {} doesn\'t exist'.format(
                    self.release_search_dir))
        elif not self.release_search_dir_abs.isdir():
            raise ReleaseUnpackerError(
                'Release search dir {} is not a dir'.format(
                    self.release_search_dir))
        elif not self.tmp_dir.exists():
            raise ReleaseUnpackerError(
                'Tmp dir {} doesn\'t exist'.format(self.tmp_dir))
        elif not self.tmp_dir.isdir():
            raise ReleaseUnpackerError(
                'Tmp dir {} is not a dir'.format(
                    self.tmp_dir))
        elif not self.unpack_dir.exists():
            raise ReleaseUnpackerError(
                'Unpack dir {} doesn\'t exist'.format(self.unpack_dir))
        elif not self.unpack_dir.isdir():
            raise ReleaseUnpackerError(
                'Unpack dir {} is not a dir'.format(
                    self.unpack_dir))
示例#25
0
 def delete_file(self, name):
     """Delete a specific file"""
     if self.ftp:
         self.ftp.delete(name)
     else:
         path = Path(self.path).child(name)
         path.remove()
示例#26
0
class Test_Inupypi(unittest.TestCase):
    def setUp(self):
        self.app = inupypi.app.test_client()
        self.workspace = Path(tempfile.mkdtemp())
        self.packages = ['p1', 'p2', 'p3', 'p4']
        self.files = ['f1', 'f2', 'f3', 'f4']
        self.app.application.config['INUPYPI_REPO'] = self.workspace

    def tearDown(self):
        self.workspace.rmtree()

    def test_app_with_missing_package_dir(self):
        self.app.application.config['INUPYPI_REPO'] = Path(self.workspace, 'a')
        assert self.app.get('/').status_code == 500
        assert '500:' in self.app.get('/').data

    def test_app_without_packages(self):
        assert 'inetutils PyPI Server' in self.app.get('/').data
        assert 'Available Packages' not in self.app.get('/').data

    def test_app_with_package_folders(self):
        env_create_packages(self.workspace, self.packages)
        env_create_package_files(self.workspace, self.packages, self.files)
        assert 'inetutils PyPI Server' in self.app.get('/').data
        assert 'Available EggBaskets' in self.app.get('/').data

    def test_app_package(self):
        env_create_packages(self.workspace, self.packages)

        for p in self.packages:
            for f in self.files:
                page = self.app.get('/'+p+'/').data
                assert '404 - Page not found' not in page
                assert f not in page

        env_create_package_files(self.workspace, self.packages, self.files)

        for p in self.packages:
            for f in self.files:
                assert f in self.app.get('/test/'+p+'/').data

    def test_app_package_file(self):
        env_create_packages(self.workspace, self.packages)

        for p in self.packages:
            for f in self.files:
                response = self.app.get('/test/'+p+'/get/'+f)
                assert response.status_code == 404

        env_create_package_files(self.workspace, self.packages, self.files)

        for p in self.packages:
            for f in self.files:
                f = '%s.tar.gz' % f
                response = self.app.get('/test/'+p+'/get/'+f)
                assert response.status_code == 200
                assert response.content_type == 'application/x-tar'
                assert response.headers.get('Content-Disposition') == \
                        'attachment; filename=%s' % f
 def test_pdf_to_png(self):
     testdir = Path(r"C:\tmp\pdfprocessing\test")
     testdir.chdir()
     input_file = "testpdf.pdf"
     output_file = Path(r"C:\tmp\pdfprocessing\test\test_gs_pdf_to_png.png")
     gs = GhostScript()
     gs.pdf_to_png(input_file,output_file)
     self.assertTrue(output_file.exists(),"File")
示例#28
0
文件: travel.py 项目: Krazylee/travel
 def normalize_element(self, path_val):
     path = Path(path_val)
     # /foo
     if path.isabsolute():
         return path.expand()
     # foo
     else:
         return Path(self.root, path_val)
示例#29
0
文件: info.py 项目: hallaj/inupypi
    def __init__(self, path):
        try:
            path = Path(path)

            self.__parents__ = path
            self.__contents__ = [d.name for d in path.listdir()]
        except:
            pass
示例#30
0
文件: user.py 项目: Codevolve/pyolite
 def delete(self, name):
     user = User(self.path, self.git, name)
     dest = Path(self.path, 'keydir/%s' % name)
     if not dest.exists():
         raise ValueError('Repository %s not existing.' % name)
     dest.rmtree()
     self.git.commit([str(dest)], 'Deleted user %s.' % name)
     
     return user
示例#31
0
Generated by 'django-admin startproject' using Django 3.0.4.

For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
from unipath import Path

BASE_DIR = Path(__file__).ancestor(3)

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '0dpa2r3fsz47cdjofv915e2r1fm&%k_zl89oh(jf4q@e@2dxff'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['*']


# Application definition
示例#32
0
    'host': 'localhost',
    'demo': ''  #'minimal'
}
#  MySQL
# env.db['url'] = 'mysql://%(user)s:%(pass)s@%(host)s:%(port)d/%(name)s' % env.db

#  PostgreSQL
env.db['driver'] = 'pdo_pgsql'  # you can choose from mysql|postgresql|sqlite
env.db['port'] = 5432
env.db[
    'url'] = 'postgres://%(user)s:%(pass)s@%(host)s:%(port)d/%(name)s' % env.db

env.db_str = ''  # db setting string conf file
env.ssl_str = None  # ssl support

env.home = Path('/', 'home', env.user)
env.ssh = '/home/%s/.ssh' % env.user

env.local_root = Path(__file__).ancestor(2)
env.projects_dir = Path('/', 'home', env.user, 'projects')
env.project_dir = Path(env.projects_dir, env.project)
env.docroot = Path(env.project_dir, 'web')
env.downloads = Path('/', 'home', env.user, 'downloaded')

env.site = {
    'domain': env.domain,  # without www.
    'docroot': env.docroot,
    'ssl': False,
    'port': 80,
    'login': '******',
    'admin': 'admin@' + env.domain,
示例#33
0
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

from unipath import Path

BASE_DIR = Path(__file__).ancestor(3)
TEMPLATE_DIR = BASE_DIR.child("templates")
STATIC_FILE_DIR = BASE_DIR.child("static")
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ['SECRET_KEY']

# SECURITY WARNING: don't run with debug turned on in production!
ALLOWED_HOSTS = []

# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'core',
    'api',
示例#34
0
"""
Django settings for GenerarPDF project.

For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

from unipath import Path
BASE_TEMPLATES = Path(__file__).ancestor(2)

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'e!s9fvnn0sq7e7w3o%84-*53k%tie_b6bj6ipz9$)-mdrz)od('

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []

# Application definition
示例#35
0
"""Unit tests for keysight/e4411b.py.
"""
# Try to future proof code so that it's Python 3.x ready
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import

import unittest
import logging

from unipath import Path

from keysight import e4411b

TEST_DIR = Path(__file__).ancestor(1)

# Setup logging
logging.basicConfig(
    level=logging.DEBUG,
    format=' %(asctime)s -  %(levelname)s - %(message)s'
)


class TestReadingCSVFiles(unittest.TestCase):

    def setUp(self):
        test_csv_file = Path(TEST_DIR, 'sample_data', 'E4411DATA.CSV')
        print(test_csv_file)
        (self.header, self.data) = e4411b.read_csv_file(
            test_csv_file)
示例#36
0
from unipath import Path
# Django settings for project project.


def get_env_var(varname, default=None):
    """Get the environment variable or raise an exception."""
    try:
        return os.environ[varname]
    except KeyError:
        if default is not None:
            return default
        msg = "You must set the %s environment variable." % varname
        raise ImproperlyConfigured(msg)


PROJECT_ROOT = Path(__file__).ancestor(3)

DEBUG = False
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', '*****@*****.**'),
)

MANAGERS = ADMINS

DATABASES = {'default': dj_database_url.config()}

# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = [
示例#37
0
Generated by 'django-admin startproject' using Django 1.9.6.

For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import os
from django.core.urlresolvers import reverse_lazy

#NOS DEVUELVE LA RUTA PRINCIPAL DEL PROYECTO
from unipath import Path

RUTA_PROYECTO = Path(__file__).ancestor(2)

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

STATIC_ROOT = os.path.join(RUTA_PROYECTO, 'staticfiles')

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '8-w_v^l87curqfr=gu@mkd1@prxam9_w!er+83whi@fh1k1z$!'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
示例#38
0
Generated by 'django-admin startproject' using Django 2.1.

For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""
import django_heroku
import os
from unipath import Path
from decouple import config, Csv

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = Path(__file__).parent

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get(
    'SECRET_KEY',
    "faf541d1cdd7da1d485ccd6c27de8a9cc8a29434e3d1e307e250e2ee25ff4b23")
# GITHUB_SECRET_KEY = config('GITHUB_SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['*']
# ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=Csv())
示例#39
0
import sys

from unipath import Path
from installed_apps import DJANGO_APPS, THIRD_PARTY_APPS, EDC_APPS, LIS_APPS, LOCAL_APPS

from .databases import TESTING_SQLITE
from .databases import TESTING_MYSQL
from .databases import PRODUCTION_MYSQL

DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (('erikvw', 'ew@[email protected]'), )

# Path
DIRNAME = os.path.dirname(os.path.abspath(__file__))  # needed??
SOURCE_ROOT = Path(os.path.dirname(os.path.realpath(__file__))).ancestor(
    3)  # e.g. /home/django/source

SOURCE_DIR = Path(__file__).ancestor(3)
PROJECT_DIR = Path(__file__).ancestor(2)
ETC_DIR = PROJECT_DIR.child('config').child(
    'etc')  # for production this should be /etc/edc
EDC_DIR = SOURCE_ROOT.child('edc_project').child(
    'edc')  # e.g. /home/django/source/edc_project/edc
TEMPLATE_DIRS = (EDC_DIR.child('templates'), )
FIXTURE_DIRS = (PROJECT_DIR.child('apps', 'bcpp', 'fixtures'), )

MEDIA_ROOT = PROJECT_DIR.child('media')
STATIC_ROOT = PROJECT_DIR.child('static')
PROJECT_ROOT = Path(__file__).ancestor(
    3)  # e.g. /home/django/source/bhp066_project
示例#40
0
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as TCP
from unipath import Path
import dj_database_url
from decouple import config, Csv
from mendeley import Mendeley

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
CSRF_COOKIE_SECURE = config('CSRF_COOKIE_SECURE', default=True, cast=bool)
SESSION_COOKIE_SECURE = config('SESSION_COOKIE_SECURE',
                               default=True,
                               cast=bool)

PROJECT_DIR = Path(__file__).parent

DEBUG = config('DEBUG', default=False, cast=bool)
TEMPLATE_DEBUG = DEBUG

DATABASES = {'default': dj_database_url.config(default=config('DATABASE_URL'))}

ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=Csv())

ADMINS = (('Vitor Freitas', '*****@*****.**'), )

MANAGERS = ADMINS

TIME_ZONE = 'UTC'
LANGUAGE_CODE = 'en-us'

USE_I18N = True
USE_L10N = True
USE_TZ = True
示例#41
0
Generated by 'django-admin startproject' using Django 3.0.6.

For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""

from django.core.exceptions import ImproperlyConfigured
import json

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
from unipath import Path
BASE_DIR = Path(__file__).ancestor(3)

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
########## Secret file #################
with open("secret.json") as f:
    secret = json.loads(f.read())


def get_secret(secret_name, secrets=secret):
    try:
        return secrets[secret_name]
    except:
        msg = "la variable %s no existe" % secret_name
示例#42
0
import os
from decouple import Csv, config, UndefinedValueError
from unipath import Path
import stip.common.const as const

PROJECT_DIR = Path(__file__).parent

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/

# SECRET_KEY = config('SECRET_KEY')
# CTIRS
SECRET_KEY = 'j%yjl@$v=xi6((y3!=bf3$n5)e)+af)*+syuia#co)1edp=dv-'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config('DEBUG', default=False, cast=bool)

mysql_user = config('MYSQL_USER')
mysql_password = config('MYSQL_PASSWORD')
try:
    mysql_dbname = config('MYSQL_DBNAME')
except UndefinedValueError:
    mysql_dbname = 's_tip'
try:
    mysql_host = config('MYSQL_HOST')
except UndefinedValueError:
    mysql_host = 'localhost'
try:
    mysql_port = config('MYSQL_PORT')
except UndefinedValueError:
    mysql_port = '3306'
示例#43
0
MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware'
]

ROOT_URLCONF = 'config.urls'

AUTH_USER_MODEL = 'texts_admin.TextsAdmin'

BASE_DIR = Path(__file__).absolute().ancestor(3)
STATIC_ROOT = BASE_DIR.child('static')
STATIC_VERSION = '1.0.0'

STATICFILES_DIRS = (BASE_DIR.child('assets'), )

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            BASE_DIR.child('templates'),
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
示例#44
0
# Production settings
import os
from unipath import Path

PROJECT_ROOT = Path(__file__).ancestor(2)

DEBUG = False

TEMPLATE_DEBUG = DEBUG

ADMINS = (("Paul Hallett", "*****@*****.**"),)

EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

MANAGERS = ADMINS

BASE_URL = "http://cluster.nicolevanderhoeven.com"

# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ["*"]

TIME_ZONE = "Europe/London"

LANGUAGE_CODE = "en-gb"

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
示例#45
0
 def setUp(self):
     test_csv_file = Path(TEST_DIR, 'sample_data', 'E4411DATA.CSV')
     print(test_csv_file)
     (self.header, self.data) = e4411b.read_csv_file(
         test_csv_file)
示例#46
0
# Log settings
LOG_LEVEL = logging.INFO
HAS_SYSLOG = config('HAS_SYSLOG', default=True, cast=bool)
LOGGING_CONFIG = None

SYSLOG_TAG = config('SYSLOG_TAG', default="http_app_mozillians")
LOGGING = {
    'loggers': {
        'landing': {'level': logging.INFO},
        'phonebook': {'level': logging.INFO},
    },
}

# Repository directory
ROOT = Path(__file__).parent.parent

# Database settings
DATABASES = {
    'default': config('DATABASE_URL', cast=db_url)
}

DATABASE_ROUTERS = ('multidb.PinningMasterSlaveRouter',)
SLAVE_DATABASES = []

# L10n
TIME_ZONE = config('TIME_ZONE', default='America/Los_Angeles')
USE_I18N = config('USE_I18N', default=True, cast=bool)
USE_L10N = config('USE_L10N', default=True, cast=bool)
TEXT_DOMAIN = 'django'
STANDALONE_DOMAINS = [TEXT_DOMAIN, 'djangojs']
示例#47
0
#import os se elimina para ser reemplazado por unipath
from unipath import Path

BASE_DIR = Path(__file__).ancestor(3)

SECRET_KEY = 'r6_(rr_rd$wc9u!mpoty%g-kmp$&#fz^7e!xjavr%0!t2gk9$1'

#TUPLA PARA APLICACIONES NETAMENTE DE DJANGO
DJANGO_APPS = (
    'django_admin_bootstrapped.bootstrap3',
    'django_admin_bootstrapped',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
)

#PARA APLICACIONES DE TERCEROS
THIRD_PARTY_APPS = (
    'south',
    'social.apps.django_app.default',  #instalarndo social login despues hay que sincronizar la db
    'djrill',  #para emal de notificacion mandril
    #'debug_toolbar',
)

#APLICACIONES LOCALES
LOCAL_APPS = (
    'apps.home',
    'apps.users',
示例#48
0
Generated by 'django-admin startproject' using Django 1.9.6.

For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""

import os
from unipath import Path
from config import *
from django_param import SECRET_KEY

PROJECT_DIR = Path(__file__).parent.parent

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

#ALLOWED_HOSTS = ['.columns.fr']
ALLOWED_HOSTS = ['*']

LOGIN_URL = '/authenticate/connexion'
# SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
示例#49
0
# Django settings for projectofinal project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', '*****@*****.**'),
)

MANAGERS = ADMINS

from unipath import Path

RUTA_PROYECTO = Path(__file__).ancestor(2)

DATABASES = {
    'default': {
        'ENGINE':
        'django.db.backends.sqlite3',  # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME':
        'projectofinal.db',  # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': '',
        'PASSWORD': '',
        'HOST':
        '',  # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': '',  # Set to empty string for default.
    }
}

# Hosts/domain names that are valid for this site; required if DEBUG is False
示例#50
0
import os
import sys

from unipath import Path
from decouple import config
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)

BASE_DIR = Path(__file__).ancestor(3)

sys.path.append(BASE_DIR.child('apps'))

SECRET_KEY = config('SECRET_KEY')

# Application definition

THIRDY_APPS = [
    'rest_framework',
    'rest_framework.authtoken',
]

OWNER_APPS = [
    'accounts.apps.AccountsConfig',
]

DJANGO_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
示例#51
0
def base_directory():
    return Path(__file__).ancestor(3)
示例#52
0
# -*- encoding: utf-8 -*-
"""
Copyright (c) 2019 - present AppSeed.us
"""

import os
from decouple import config
from unipath import Path
# import django_heroku
from dotenv import load_dotenv
from pathlib import Path  # Python 3.6+ only
env_path = Path('.') / '.env'
load_dotenv(dotenv_path=env_path)

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_DIR = Path(__file__).parent

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config('SECRET_KEY', default='S#perS3crEt_1122')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config('DEBUG', default=False)

# load production server from .env
ALLOWED_HOSTS = [
    'localhost', '127.0.0.1',
    config('SERVER', default='127.0.0.1'), '14.232.213.52', 'aqm-vass.tk',
    'aqm-vasc.tk'
]
示例#53
0
    Configuración básica (que comparten ambos entornos desarollo y productivo)
    que se hereda tanto al entorno local y producción.
"""

import os

from unipath import Path

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
"""
    Se cambia BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    a Path(__file__).ancestor(3) (Configuración con unipath). Tomara el directorio
    general medical de la carpeta del proyecto.
"""

BASE_DIR = Path(__file__).ancestor(3)

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'm!8y_%gi!^ojb*wb^3t01vz^d+7l%yr=oons*!9!#5*&$s(9=n'

# Application definition

DJANGO_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
示例#54
0
class BatchWriter(object):
    def __init__(self,
                 data_path,
                 img_size=32,
                 channels=3,
                 max_batch_size=10000):
        self.data_path = Path(data_path).child('batches')
        if not self.data_path.exists():
            self.data_path.mkdir(parents=True)
        self.img_size = img_size
        self.channels = channels
        self.max_batch_size = max_batch_size
        self.datasets = {}
        self.next_batch = 1
        self.train_range = None
        self.test_range = None

    def prepare_training(self, train_dset, test_dset):
        if train_dset is not None:
            train_data = self.preprocess_data(train_dset.data)
            train_batch_size = self.calculate_batch_size(train_data.shape[0])
            self.train_range = self.dump_batches(train_data, train_dset.output,
                                                 train_dset.filenames,
                                                 train_batch_size)
        test_data = self.preprocess_data(test_dset.data)
        test_batch_size = self.calculate_batch_size(test_data.shape[0])
        self.test_range = self.dump_batches(test_data, test_dset.output,
                                            test_dset.filenames,
                                            test_batch_size)
        if train_dset is None:
            label_names = test_dset.labels.copy()
            data = test_data
            batch_size = test_batch_size
        else:
            label_names = train_dset.labels.copy()
            label_names.update(test_dset.labels)
            data = np.vstack((train_data, test_data))
            batch_size = train_batch_size
        self.dump_meta_batch(data, label_names, batch_size)

    def dump_meta_batch(self, data, label_names, batch_size):
        mean = data.transpose().mean(axis=1).reshape((-1, 1))
        data_path = self.data_path.child('batches.meta')
        self.write_cifar_meta_batch(data_path, mean, label_names, batch_size)

    def dump_batches(self, data, output, filenames, batch_size):
        start_batch = self.next_batch
        for i, mark in enumerate(range(0, data.shape[0], batch_size)):
            slice_ = slice(mark, mark + batch_size)
            self.write_cifar_batch(
                self.data_path.child('data_batch_' + str(self.next_batch)),
                data[slice_].transpose(), output[slice_], filenames[slice_])
            self.next_batch += 1
        return start_batch, self.next_batch - 1

    def write_cifar_batch(self, data_path, data, labels, filenames):
        data = {
            'batch_label': '',
            'labels': labels,
            'data': data,
            'filenames': filenames,
        }
        with open(data_path, 'wb') as f:
            cPickle.dump(data, f)

    def write_cifar_meta_batch(self, data_path, mean, label_names, batch_size):
        data = {
            'data_mean': mean,
            'label_names': label_names,
            'num_cases_per_batch': batch_size,
            'num_vis': mean.shape[0]
        }
        with open(data_path, 'wb') as f:
            cPickle.dump(data, f)

    def preprocess_data(self, dset_data):
        dset_size = int(np.sqrt(dset_data.shape[1] / self.channels))
        data = np.empty((dset_data.shape[0], self.img_size**2 * self.channels),
                        dtype=np.uint8)
        if self.img_size != dset_size:
            for i in range(data.shape[0]):
                image = ConvImage.from_array(dset_data[i], self.channels,
                                             dset_size)
                image.to_size(self.img_size)
                data[i] = image.to_array()
            return data
        return dset_data

    def get_data_options(self):
        return [
            '--data-path=%s' % self.data_path,
            '--train-range=%s-%s' % self.train_range,
            '--test-range=%s-%s' % self.test_range,
            '--img-size=%s' % self.img_size, '--data-provider=cifar'
        ]

    def get_data_options_test(self):
        return [
            '--data-dir=%s' % self.data_path,
            '--test-range=%s-%s' % self.test_range, '--is-dataset=1'
        ]

    def calculate_batch_size(self, data_size):
        if data_size % self.max_batch_size == 0:
            return self.max_batch_size
        c = data_size / self.max_batch_size + 1
        return data_size / c
示例#55
0
# -*- encoding: utf-8 -*-
"""
Copyright (c) 2019 - present AppSeed.us
"""

import os
from unipath import Path
import dj_database_url

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = Path(__file__).parent
CORE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'mb$+6q9vzgba@is1bv#$bk$4z4sj*ri)s!x)dcdylmobjn8qzu'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

# load production server from .env
ALLOWED_HOSTS = []

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
示例#56
0
"""
DB router for Trac. Very simple: just makes sure that all Trac tables are
queries against the "trac" DB alias.

It's very simplistic, leaving off allow_relation and allow_syncdb since all
the Trac apps are unmanaged.
"""

from unipath import FSPath as Path

THIS_APP = Path(__file__).parent.name


class TracRouter(object):
    def db_for_read(self, model, **hints):
        return 'trac' if app_label(model) == THIS_APP else None

    def db_for_write(self, model, **hints):
        return 'trac' if app_label(model) == THIS_APP else None


def app_label(model):
    return model._meta.app_label
示例#57
0
# Django settings for ondeeuparei project.
from unipath import Path
import dj_database_url

PROJECT_DIR = Path(__file__).parent
DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', '*****@*****.**'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': dj_database_url.config(default='sqlite:///' + PROJECT_DIR.child('ondeeuparei.db'))
}

# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = []

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'America/Sao_Paulo'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en'
示例#58
0
from unipath import Path
TEST_RUN = True
API_SERVER = 'http://localhost:8999'
WORKER_KEY = ''
BROKER_HOST = "localhost"
BROKER_PORT = 5672
BROKER_USER = "******"
BROKER_PASSWORD = "******"
BROKER_VHOST = "/ersatz_test"
AWS_ACCESS_KEY = "AKIAJ2Z5C7C2QXRNFX5Q"
AWS_SECRET_KEY = "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"
S3_BUCKET = 'ersatz1test'

LOGLEVEL = 'WARNING'

PROJECT_DIR = Path(__file__).ancestor(2)
SPEARMINT = PROJECT_DIR.child('spearmint-lite')
CONVNET = PROJECT_DIR.child('convnet')
WORKING_DIR = PROJECT_DIR.child('work', 'test')
S3_CACHEDIR = WORKING_DIR.child('cache')
RUN_IN_SUBPROCESS = True
DATASET_VERSION = 1
示例#59
0
import os
import dj_database_url
from unipath import Path

PROJECT_DIR = Path(__file__).parent.parent
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get('SECRET_KEY', 'secret123')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['bachoter.herokuapp.com']

# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# Update database configuration with $DATABASE_URL.
DATABASES = {
    'default': dj_database_url.config(conn_max_age=500)
}

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticroot')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
    os.path.join(os.path.dirname(PROJECT_ROOT), 'static'),
示例#60
0
# Django settings for tango project.
from unipath import Path
import dj_database_url

PROJECT_PATH = Path.cwd()
TEMPLATE_PATH = Path(PROJECT_PATH, 'templates')
STATIC_PATH = Path(PROJECT_PATH, 'static')
MEDIA_ROOT = Path(PROJECT_PATH, 'media')

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', '*****@*****.**'),
)

MANAGERS = ADMINS

DATABASES = {
    'default':
    dj_database_url.config(default="postgres://jonathan@localhost:5432/rango")
}

LOGIN_URL = '/rango/login/'

# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = []

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name