Skip to content

Commit

Permalink
convert tabs to spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
ghukill committed May 14, 2019
1 parent d16c1d3 commit cfd3bf5
Show file tree
Hide file tree
Showing 34 changed files with 10,372 additions and 10,766 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,6 @@ combine/localsettings.py

# Combine static files
/static

# PyCharm IDE
.idea
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
### Changed
- Update XML2kvp to limit values at 32k characters [#403](https://github.com/WSULib/combine/issues/403)
- Converting tabs to spaces per PEP 8 recs


## `v0.8`
Expand Down
27 changes: 1 addition & 26 deletions combine/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,23 @@

import os


# Combine Version
COMBINE_VERSION = 'v0.9'


# 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.11/howto/deployment/checklist/


# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '$)1(piv72**m&3bmb)j!=f-h4=of6_knu=c8lj31n7k=y36oi%'


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


ALLOWED_HOSTS = ['*'] # for dev, allowing all hosts

ALLOWED_HOSTS = ['*'] # for dev, allowing all hosts

# Application definition

Expand Down Expand Up @@ -83,7 +77,6 @@

WSGI_APPLICATION = 'combine.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

Expand Down Expand Up @@ -134,13 +127,11 @@

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = '/opt/combine/static'


# Logging
LOGGING = {
'version': 1,
Expand Down Expand Up @@ -188,7 +179,6 @@
},
}


# shell_plus additional imports
SHELL_PLUS_POST_IMPORTS = {
('inc.console', '*')
Expand All @@ -201,18 +191,3 @@
from combine.localsettings import *
except ImportError:
pass















2 changes: 1 addition & 1 deletion combine/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
from django.contrib import admin

urlpatterns = [
url(r'^combine/', include('core.urls')),
url(r'^combine/', include('core.urls')),
url(r'^admin/', admin.site.urls),
]
2 changes: 1 addition & 1 deletion core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# Django starts so that shared_task will use this app.
from .celery import celery_app

__all__ = ('celery_app',)
__all__ = ('celery_app',)
6 changes: 4 additions & 2 deletions core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

from django.contrib import admin

from .models import Organization, RecordGroup, Job, OAIEndpoint, LivySession, Transformation, ValidationScenario, RecordIdentifierTransformationScenario, DPLABulkDataDownload, FieldMapper
from .models import Organization, RecordGroup, Job, OAIEndpoint, LivySession, Transformation, ValidationScenario, \
RecordIdentifierTransformationScenario, DPLABulkDataDownload, FieldMapper

# register models
admin.site.register([Organization, RecordGroup, Job, OAIEndpoint, LivySession, Transformation, ValidationScenario, RecordIdentifierTransformationScenario, DPLABulkDataDownload, FieldMapper])
admin.site.register([Organization, RecordGroup, Job, OAIEndpoint, LivySession, Transformation, ValidationScenario,
RecordIdentifierTransformationScenario, DPLABulkDataDownload, FieldMapper])
51 changes: 24 additions & 27 deletions core/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,38 @@
# Get an instance of a logger
logger = logging.getLogger(__name__)


# NOTE: manual configuration of core app not currently used, but leaving if needed
class CoreConfig(AppConfig):
name = 'core'

name = 'core'

def ready(self):

'''
ready() method fires once, when application is loaded and ready
https://docs.djangoproject.com/en/dev/ref/applications/#django.apps.AppConfig.ready
This fires any functions defined here that are needed when Combine starts.
Args:
(django.apps.AppConfig): instance of 'Core' application config
def ready(self):
'''
ready() method fires once, when application is loaded and ready
https://docs.djangoproject.com/en/dev/ref/applications/#django.apps.AppConfig.ready
Returns:
None
'''
This fires any functions defined here that are needed when Combine starts.
logger.debug('Core application ready method preperations firing')
Args:
(django.apps.AppConfig): instance of 'Core' application config
# create home working directory
self.create_home_working_directory()
Returns:
None
'''

logger.debug('Core application ready method preperations firing')

def create_home_working_directory(self):
# create home working directory
self.create_home_working_directory()

'''
Method to create directory /home/combine/data/combine if does not exist
'''
def create_home_working_directory(self):
'''
Method to create directory /home/combine/data/combine if does not exist
'''

# parse home working directory
hwd = settings.BINARY_STORAGE.split('file://')[-1]
# parse home working directory
hwd = settings.BINARY_STORAGE.split('file://')[-1]

# create if not exists
if not os.path.exists(hwd):
os.makedirs(hwd)
# create if not exists
if not os.path.exists(hwd):
os.makedirs(hwd)
2 changes: 1 addition & 1 deletion core/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

@celery_app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))
print('Request: {0!r}'.format(self.request))
113 changes: 48 additions & 65 deletions core/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# general
from core.celery import celery_app
from django.conf import settings
Expand All @@ -10,75 +9,59 @@


def combine_settings(request):
'''
Make some settings variables available to all templates
'''

'''
Make some settings variables available to all templates
'''

# prepare combine settings
combine_settings_keys = [
'APP_HOST',
'DPLA_API_KEY',
'OAI_RESPONSE_SIZE',
'COMBINE_OAI_IDENTIFIER',
'COMBINE_DEPLOYMENT',
'COMBINE_VERSION'
]
combine_settings_dict = { k:getattr(settings,k,None) for k in combine_settings_keys }
# prepare combine settings
combine_settings_keys = [
'APP_HOST',
'DPLA_API_KEY',
'OAI_RESPONSE_SIZE',
'COMBINE_OAI_IDENTIFIER',
'COMBINE_DEPLOYMENT',
'COMBINE_VERSION'
]
combine_settings_dict = {k: getattr(settings, k, None) for k in combine_settings_keys}

# return
return combine_settings_dict
# return
return combine_settings_dict


def livy_session(request):

'''
Make Livy session information available to all views
'''

# get active livy session
lv = LivySession.get_active_session()
if lv:
if type(lv) == LivySession:
# refresh single session
lv.refresh_from_livy()
elif type(lv) == QuerySet:
# multiple Combine LivySession founds, loop through
for s in lv:
s.refresh_from_livy()
else:
pass

return {
'LIVY_SESSION':lv
}
'''
Make Livy session information available to all views
'''

# get active livy session
lv = LivySession.get_active_session()
if lv:
if type(lv) == LivySession:
# refresh single session
lv.refresh_from_livy()
elif type(lv) == QuerySet:
# multiple Combine LivySession founds, loop through
for s in lv:
s.refresh_from_livy()
else:
pass

return {
'LIVY_SESSION': lv
}


def combine_git_info(request):

'''
Return state of HEAD for Combine git repo
'''

# one liner for branch or tag
git_head = subprocess.Popen('head_name="$(git symbolic-ref HEAD 2>/dev/null)" || head_name="$(git describe --tags)"; echo $head_name', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.read().decode('utf-8').rstrip("\n")
if "/" in git_head:
git_head = git_head.split('/')[-1]

# return
return {'COMBINE_GIT_BRANCH':git_head}















'''
Return state of HEAD for Combine git repo
'''

# one liner for branch or tag
git_head = subprocess.Popen(
'head_name="$(git symbolic-ref HEAD 2>/dev/null)" || head_name="$(git describe --tags)"; echo $head_name',
shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.read().decode('utf-8').rstrip("\n")
if "/" in git_head:
git_head = git_head.split('/')[-1]

# return
return {'COMBINE_GIT_BRANCH': git_head}
17 changes: 6 additions & 11 deletions core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@
from core.models import Organization, RecordGroup, OAIEndpoint, Transformation



class OrganizationForm(ModelForm):

class Meta:
model = Organization
fields = ['name', 'description']

class Meta:
model = Organization
fields = ['name', 'description']


class RecordGroupForm(ModelForm):

class Meta:
model = RecordGroup
fields = ['organization', 'name', 'description']

class Meta:
model = RecordGroup
fields = ['organization', 'name', 'description']
30 changes: 14 additions & 16 deletions core/management/commands/ensuremongocollections.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# generic imports
import logging

Expand All @@ -11,23 +10,22 @@
# Get an instance of a logger
logger = logging.getLogger(__name__)

class Command(BaseCommand):

help = 'Ensure Mongo collections are created, and have proper indices'

def handle(self, *args, **options):
class Command(BaseCommand):
help = 'Ensure Mongo collections are created, and have proper indices'

# Record model
logger.debug('ensuring indices for record collection')
Record.ensure_indexes()
def handle(self, *args, **options):
# Record model
logger.debug('ensuring indices for record collection')
Record.ensure_indexes()

# RecordValidation model
logger.debug('ensuring indices for record_validation collection')
RecordValidation.ensure_indexes()
# RecordValidation model
logger.debug('ensuring indices for record_validation collection')
RecordValidation.ensure_indexes()

# IndexMappingFailure model
logger.debug('ensuring indices for index_mapping_failures collection')
IndexMappingFailure.ensure_indexes()
# IndexMappingFailure model
logger.debug('ensuring indices for index_mapping_failures collection')
IndexMappingFailure.ensure_indexes()

# return
self.stdout.write(self.style.SUCCESS('Mongo collections and indices verified and/or created'))
# return
self.stdout.write(self.style.SUCCESS('Mongo collections and indices verified and/or created'))
Loading

0 comments on commit cfd3bf5

Please sign in to comment.