Python django.conf.settings.PROJECT_DIR Examples
The following are 14
code examples of django.conf.settings.PROJECT_DIR().
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 also want to check out all available functions/classes of the module
django.conf.settings
, or try the search function
.
Example #1
Source File: force_reinitiate_migrations.py From lexpredict-contraxsuite with GNU Affero General Public License v3.0 | 6 votes |
def handle(self, *args, **options): # 1. remove migration files custom_apps = [i.replace('apps.', '') for i in settings.INSTALLED_APPS if i.startswith('apps.')] for app_name in custom_apps: app_migrations_path = os.path.join(settings.PROJECT_DIR, f'apps/{app_name}/migrations') shutil.rmtree(app_migrations_path, ignore_errors=True) # drop migrations table with connection.cursor() as cursor: cursor.execute('DROP TABLE django_migrations;') # re-create migration files call_command('makemigrations', 'common') call_command('makemigrations') # re-fill migrations call_command('migrate', '--fake')
Example #2
Source File: views.py From esdc-ce with Apache License 2.0 | 6 votes |
def send_post_register_email(request, user): # Send optional email after successful registration (issue #261) template_path = path.join(settings.PROJECT_DIR, 'gui', 'templates') subject = 'gui/accounts/post_register_subject.txt' subject_path = path.join(template_path, subject) body_file_prefix = 'gui/accounts/post_register_email' body = None if path.exists(subject_path) and path.exists(path.join(template_path, body_file_prefix + '.html')): body = body_file_prefix + '.html' elif path.exists(subject_path) and path.exists(path.join(template_path, body_file_prefix + '.txt')): body = body_file_prefix + '.txt' if body: sendmail(user, subject, body, dc=request.dc) else: logger.info('Post registration email subject template: "%s" or body template: "%s" does not exists.' % (subject_path, path.join(template_path, body_file_prefix + '.[html|txt]')))
Example #3
Source File: views.py From bctip with MIT License | 6 votes |
def download(request, key, format, page_size="A4"): wallet = get_object_or_404(Wallet, key=key) page_size_prefix = "" if page_size == "US": page_size_prefix = "us-" fn = '/static/%s/tips-%s%s.%s' % (format, page_size_prefix, wallet.key, format) i = 0 while not os.path.exists("%s/%s" % (settings.PROJECT_DIR, fn)): if i == 0: result = celery_generate_pdf.delay(wallet) time.sleep(25) if i > 0: ctx = {'result': result.ready(), 'info': result.info} return render_to_response("not_yet.html", context_instance=RequestContext(request, ctx)) i += 1 return HttpResponseRedirect(fn)
Example #4
Source File: load_roles.py From lexpredict-contraxsuite with GNU Affero General Public License v3.0 | 5 votes |
def handle(self, *args, **options): if not Role.objects.exists(): fixture_path = os.path.join( str(settings.PROJECT_DIR), 'fixtures', 'common', '1_Role.json' ) call_command('loaddata', fixture_path, app_label='users')
Example #5
Source File: utils.py From lexpredict-contraxsuite with GNU Affero General Public License v3.0 | 5 votes |
def download_pdf(data: pd.DataFrame, file_name='output'): data_html = data.to_html(index=False) try: data_pdf = pdf.from_string(data_html, False) except OSError: env = Environment(loader=FileSystemLoader(settings.PROJECT_DIR('templates'))) template = env.get_template('pdf_export.html') template_vars = {"title": file_name.capitalize(), "table": data_html} data_pdf = HTML(string=template.render(template_vars)).write_pdf() response = HttpResponse(content_type='application/pdf') response['Content-Disposition'] = 'attachment; filename="{}.{}"'.format(file_name, 'pdf') response.write(data_pdf) return response
Example #6
Source File: load_review_status_groups.py From lexpredict-contraxsuite with GNU Affero General Public License v3.0 | 5 votes |
def handle(self, *args, **options): if not ReviewStatusGroup.objects.exists(): fixture_path = os.path.join( str(settings.PROJECT_DIR), 'fixtures', 'common', '2_ReviewStatusGroup.json' ) call_command('loaddata', fixture_path, app_label='common')
Example #7
Source File: load_review_statuses.py From lexpredict-contraxsuite with GNU Affero General Public License v3.0 | 5 votes |
def handle(self, *args, **options): if not ReviewStatus.objects.exists(): fixture_path = os.path.join( str(settings.PROJECT_DIR), 'fixtures', 'common', '3_ReviewStatus.json' ) call_command('loaddata', fixture_path, app_label='common')
Example #8
Source File: load_annotation_statuses.py From lexpredict-contraxsuite with GNU Affero General Public License v3.0 | 5 votes |
def handle(self, *args, **options): if not FieldAnnotationStatus.objects.exists(): fixture_path = os.path.join( str(settings.PROJECT_DIR), 'fixtures', 'common', '4_FieldAnnotationStatus.json' ) call_command('loadnewdata', fixture_path, app_label='common')
Example #9
Source File: plugin.py From sal with Apache License 2.0 | 5 votes |
def get(cls): if cls.__instance is None: # initialise the 'inner' PluginManagerDecorator cls.__instance = yapsy.PluginManager.PluginManager() cls.__instance.setPluginPlaces([settings.PLUGIN_DIR, os.path.join( settings.PROJECT_DIR, 'server/plugins')]) cls.__instance.collectPlugins() # Move this attribute because we don't use the container # object in Sal. Set it once here rather than at every # retrieval! for plugin in cls.__instance.getAllPlugins(): plugin.plugin_object.path = plugin.path logger.debug("PluginManagerSingleton initialised") return cls.__instance
Example #10
Source File: utils.py From cartoview with BSD 2-Clause "Simplified" License | 5 votes |
def create_apps_dir(apps_dir=getattr(settings, 'APPS_DIR', None)): if not apps_dir: project_dir = getattr(settings, 'BASE_DIR', settings.PROJECT_DIR) apps_dir = os.path.abspath(os.path.join( os.path.dirname(project_dir), "apps")) if not os.path.exists(apps_dir): create_direcotry(apps_dir) if not os.access(apps_dir, os.W_OK): change_path_permission(apps_dir)
Example #11
Source File: api_views.py From esdc-ce with Apache License 2.0 | 5 votes |
def ssl_certificate(self): """PUT /system/settings/ssl-certificate - runs a script, which checks the certificate by running openssl, replaces the PEM file and reloads haproxy""" assert self.request.dc.id == DefaultDc().id ser = SSLCertificateSerializer(self.request, data=self.data) if not ser.is_valid(): return FailureTaskResponse(self.request, ser.errors, dc_bound=False) cert = ser.object['cert'] update_script = os.path.join(settings.PROJECT_DIR, self.SSL_CERTIFICATE_UPDATE_CMD) res = { 'action': 'SSL Certificate Update', 'returncode': '???', 'message': '' } cert_file = NamedTemporaryFile(dir=settings.TMPDIR, mode='w', delete=False) cert_file.write(cert) cert_file.close() try: proc = Popen(['sudo', update_script, cert_file.name], bufsize=0, close_fds=True, stdout=PIPE, stderr=STDOUT) res['message'], _ = proc.communicate() res['returncode'] = proc.returncode finally: os.remove(cert_file.name) if proc.returncode == 0: response_class = SuccessTaskResponse else: response_class = FailureTaskResponse return response_class(self.request, res, msg=LOG_SYSTEM_SETTINGS_UPDATE, detail_dict=res, dc_bound=False)
Example #12
Source File: init.py From esdc-ce with Apache License 2.0 | 5 votes |
def _es_api_url(site_link): """Update API_URL in es""" es_src = os.path.join(settings.PROJECT_DIR, 'bin', 'es') es_dst = os.path.join(settings.PROJECT_DIR, 'var', 'www', 'static', 'api', 'bin', 'es') api_url = "API_URL = '%s'" % (site_link + '/api') logger.info('Replacing API_URL in %s with "%s"', es_dst, api_url) with open(es_src) as es1: # noinspection PyTypeChecker with os.fdopen(os.open(es_dst, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o644), 'w') as es2: es2.write(es1.read().replace("API_URL = 'http://127.0.0.1:8000/api'", api_url))
Example #13
Source File: _base.py From esdc-ce with Apache License 2.0 | 5 votes |
def get_git_version(self): with lcd(self.PROJECT_DIR): _tag = self.local(self.cmd_tag, capture=True).strip().split('/')[-1] _sha = self.local(self.cmd_sha, capture=True).strip() return _tag, _sha
Example #14
Source File: tasks.py From bctip with MIT License | 4 votes |
def celery_generate_pdf(wallet): activate(wallet.target_language) tips = Tip.objects.filter(wallet=wallet).order_by('id') ctx = {'wallet':wallet, 'tips':tips} ctx['cur_sign'] = CURRENCY_SIGNS[wallet.divide_currency] #print "asdff" #_startDate = home.home_startdate.strftime('%m/%d/%Y') # let's begin unique_tmp = '/tmp/w%s.odt'%wallet.id shutil.copyfile(settings.WEBODT_TEMPLATE_PATH +"/"+ wallet.template, unique_tmp) inpt = zipfile.ZipFile(unique_tmp, "a" ) text = StringIO.StringIO() for tip in tips: inpt.writestr("Pictures/%s.png"%tip.id, qrcode_img(tip.get_absolute_url()) ) manifest = Template( inpt.read( 'META-INF/manifest.xml' ) ) inpt.writestr("META-INF/manifest.xml", manifest.render( Context(ctx) )) inpt.close() # fuu #template = webodt.ODFTemplate(unique_tmp) #webodt.HTMLTemplate('test.html') #document = template.render(Context(ctx)) document = odt_template(unique_tmp, Context(ctx)) document_us = odt_template(unique_tmp, Context(ctx), page_size="US") #odt fn = settings.PROJECT_DIR+"/static/odt/tips-%s.odt"%wallet.key f = open(fn,'w') f.write(document) f.close() fn = settings.PROJECT_DIR+"/static/odt/tips-us-%s.odt"%wallet.key f = open(fn,'w') f.write(document_us) f.close() #pdf s=["unoconv", "-f", "pdf", "-o", settings.PROJECT_DIR+"/static/pdf/tips-%s.pdf"%wallet.key, settings.PROJECT_DIR+"/static/odt/tips-%s.odt"%wallet.key] subprocess.call(s) subp = subprocess.Popen(s, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) retval = subp.wait() s=["unoconv", "-f", "pdf", "-o", settings.PROJECT_DIR+"/static/pdf/tips-us-%s.pdf"%wallet.key, settings.PROJECT_DIR+"/static/odt/tips-us-%s.odt"%wallet.key] subprocess.call(s) subp = subprocess.Popen(s, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) retval = subp.wait() #png s=["convert", "-density", "300", "-trim", settings.PROJECT_DIR+"/static/pdf/tips-%s.pdf"%wallet.key, settings.PROJECT_DIR+"/static/png/tips-%s.png"%wallet.key] subprocess.call(s) subp = subprocess.Popen(s, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) retval = subp.wait() return True