Python django.conf.settings.PROJECT_ROOT Examples
The following are 4
code examples of django.conf.settings.PROJECT_ROOT().
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: event_import.py From linkedevents with MIT License | 5 votes |
def handle(self, *args, **options): module = options['module'] if module not in self.importers: raise CommandError("Importer %s not found. Valid importers: %s" % (module, self.imp_list)) imp_class = self.importers[module] if hasattr(settings, 'PROJECT_ROOT'): root_dir = settings.PROJECT_ROOT else: root_dir = settings.BASE_DIR importer = imp_class({'data_path': os.path.join(root_dir, 'data'), 'verbosity': int(options['verbosity']), 'cached': options['cached'], 'single': options['single'], 'remap': options['remap'], 'force': options['force']}) # Activate the default language for the duration of the import # to make sure translated fields are populated correctly. old_lang = get_language() activate(settings.LANGUAGES[0][0]) for imp_type in self.importer_types: name = "import_%s" % imp_type method = getattr(importer, name, None) if options[imp_type]: if not method: raise CommandError("Importer {} does not support importing {}".format(importer.name, imp_type)) if imp_type == 'courses' and 'extension_course' not in settings.INSTALLED_APPS: raise CommandError("Course extension must be installed when importing courses.") else: if not options['all']: continue if method: method() activate(old_lang)
Example #2
Source File: copy_media.py From wagtail-cookiecutter-foundation with MIT License | 5 votes |
def handle(self, **options): media_src_dir = os.path.join(settings.PROJECT_ROOT, 'pages', 'media') image_src_dir = os.path.join(media_src_dir, 'images') image_src_dir_or = os.path.join(media_src_dir, 'original_images') documents_src_dir = os.path.join(media_src_dir, 'documents') image_dest_dir_or = os.path.join(settings.MEDIA_ROOT, 'original_images') image_dest_dir = os.path.join(settings.MEDIA_ROOT, 'images') documents_dest_dir = os.path.join(settings.MEDIA_ROOT, 'documents') if not os.path.isdir(image_dest_dir): os.makedirs(image_dest_dir) for filename in os.listdir(image_src_dir): shutil.copy(os.path.join(image_src_dir, filename), image_dest_dir) if not os.path.isdir(image_dest_dir_or): os.makedirs(image_dest_dir_or) for filename in os.listdir(image_src_dir_or): shutil.copy( os.path.join(image_src_dir_or, filename), image_dest_dir_or ) if not os.path.isdir(documents_dest_dir): os.makedirs(documents_dest_dir) for filename in os.listdir(documents_src_dir): shutil.copy( os.path.join(documents_src_dir, filename), documents_dest_dir )
Example #3
Source File: load_initial_data.py From madewithwagtail with MIT License | 5 votes |
def handle(self, *args, **options): fixtures_dir = os.path.join(settings.PROJECT_ROOT, settings.SITE_NAME, 'core', 'fixtures') fixture_file = os.path.join(fixtures_dir, 'initial_data.json') image_src_dir = os.path.join(fixtures_dir, 'images') image_dest_dir = os.path.join(settings.MEDIA_ROOT, 'original_images') call_command('loaddata', fixture_file, verbosity=3) if not os.path.isdir(image_dest_dir): os.makedirs(image_dest_dir) for filename in os.listdir(image_src_dir): shutil.copy(os.path.join(image_src_dir, filename), image_dest_dir)
Example #4
Source File: installer.py From cartoview with BSD 2-Clause "Simplified" License | 5 votes |
def execute_command(self, command): project_dir = None if hasattr(settings, 'BASE_DIR'): project_dir = settings.BASE_DIR elif hasattr(settings, 'PROJECT_ROOT'): project_dir = settings.PROJECT_ROOT elif hasattr(settings, 'APP_ROOT'): project_dir = settings.APP_ROOT manage_py = os.path.join(project_dir, 'manage.py') process = subprocess.Popen( "{} {} {}".format(executable, manage_py, command), shell=True) out, err = process.communicate() logger.info(out) logger.error(err)