Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOI-75 Add static astroid version and fix pep8 violations. #402

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.xml_importer import import_library_from_xml


class Command(BaseCommand):
"""
Import the specified library data directory into the default ModuleStore
"""
help = """
help = """
Import the specified library(s) data directory into the default ModuleStore

Usage: cms import-library <data_directory> [--nostatic] <library_dir> [<library_dir>...]
Expand All @@ -30,33 +31,33 @@ class Command(BaseCommand):
action='store_true',
help='Skip import of static content'),
)

def handle(self, *args, **options):
"""
Execute the command
"""
do_import_static = not options.get('nostatic', False)
if len(args) < 2:
raise CommandError("ERROR: import-library requires at least two arguments: <data_directory> [--nostatic] <library_dir> [<library_dir>...]")

data_dir = args[0]
if len(args) > 1:
source_dirs = args[1:]
else:
raise CommandError("ERROR: import-library requires at least one library_dir as argument")

self.stdout.write("Importing. Data_dir={data}, source_dirs={courses}\n".format(
data=data_dir,
courses=source_dirs,
))

course_items = import_library_from_xml(
modulestore(), ModuleStoreEnum.UserID.mgmt_command, data_dir, source_dirs, load_error_modules=False,
static_content_store=contentstore(), verbose=True,
do_import_static=do_import_static,
create_if_not_present=True,
)

if course_items:
self.stdout.write("Successfully imported {} libraries.\n".format(len(course_items)))
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase


@ddt.ddt
class TestImportLibrary(ModuleStoreTestCase):
"""
Expand Down Expand Up @@ -56,7 +57,7 @@ def test_library_import(self):
Compare library_key of imported library with self-generated
"""
self.assertEqual(unicode(self.library_from_store.location.library_key), unicode(self.library_key))
"""
"""
Compare display_name of imported library with original
"""
self.assertEqual(unicode(self.library_from_store), u"Library: " + unicode(self.display_name))
Expand All @@ -66,4 +67,3 @@ def test_library_import_invalid_dirs(self, invalid_source_dir):
errstring = "Imported libraries count is zero"
with self.assertRaisesRegexp(CommandError, errstring):
call_command('import-library', self.content_dir, invalid_source_dir)

2 changes: 1 addition & 1 deletion cms/envs/static_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

EDX_PLATFORM_STATIC_ROOT_BASE = settings.STATIC_ROOT_BASE

STATIC_ROOT_BASE=os.environ.get('STATIC_COLLECTOR_ROOT', '/edx/var/edxapp/static_collector')
STATIC_ROOT_BASE = os.environ.get('STATIC_COLLECTOR_ROOT', '/edx/var/edxapp/static_collector')
STATIC_ROOT = path(STATIC_ROOT_BASE) / EDX_PLATFORM_REVISION
9 changes: 5 additions & 4 deletions lms/djangoapps/bulk_email/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,10 @@ class CourseEmail(Email):
class Meta(object):
app_label = "bulk_email"

DEFAULT_FROM_EMAIL = (settings.FEATURES.get('BULK_EMAIL_FROM_DIFFERENT_ADDRESSES')
and None
or getattr(settings, 'BULK_EMAIL_DEFAULT_FROM_EMAIL', None))
DEFAULT_FROM_EMAIL = (
settings.FEATURES.get('BULK_EMAIL_FROM_DIFFERENT_ADDRESSES') and None
or getattr(settings, 'BULK_EMAIL_DEFAULT_FROM_EMAIL', None)
)

course_id = CourseKeyField(max_length=255, db_index=True)
# to_option is deprecated and unused, but dropping db columns is hard so it's still here for legacy reasons
Expand Down Expand Up @@ -399,4 +400,4 @@ def __unicode__(self):
return u"BulkEmailFlag: enabled {}, require_course_email_auth: {}".format(
current_model.is_enabled(),
current_model.require_course_email_auth
)
)
6 changes: 3 additions & 3 deletions lms/djangoapps/certificates/tests/test_webview_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,9 +1161,9 @@ def test_certificate_evidence_event_emitted(self):
course_id=unicode(self.course.id)
)
new_user = UserFactory.create(
email='other_user@edx.org',
username='other_user',
password='foo'
email='other_user@edx.org',
username='other_user',
password='foo'
)
new_user.profile.name = "Other User"
new_user.profile.save()
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/dashboard/sysadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def post(self, request):
result_ids = [result["data"]["id"] for result in response["results"]]
self._searcher.remove('courseware_content', result_ids)
self._searcher.remove('course_info', [course_id])
except Exception as e: # pragma: no cover
except Exception as e: # pragma: no cover
log.error(e.message)

CourseOverview.objects.filter(id=course.id).delete()
Expand Down
8 changes: 6 additions & 2 deletions lms/djangoapps/instructor/enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,12 @@ def send_mail_to_student(student, param_dict, language=None):
)

try:
subject, html_message = render_message_to_string(subject_template,
html_message_template, param_dict, language=language)
subject, html_message = render_message_to_string(
subject_template,
html_message_template,
param_dict,
language=language
)
except:
html_message = None

Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/instructor_task/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ def links_for(self, course_id):
files = [(filename, os.path.join(course_dir, filename)) for filename in filenames]
files.sort(key=lambda f: self.storage.modified_time(f[1]), reverse=True)

if (settings.GRADES_DOWNLOAD['STORAGE_TYPE']=='azure' or settings.GRADES_DOWNLOAD['STORAGE_TYPE']=='s3'):
if (settings.GRADES_DOWNLOAD['STORAGE_TYPE'] == 'azure' or settings.GRADES_DOWNLOAD['STORAGE_TYPE'] == 's3'):
return [
(filename, self.storage.url(full_path))
(filename, self.storage.url(full_path))
for filename, full_path in files
]
else:
Expand Down
32 changes: 16 additions & 16 deletions lms/djangoapps/shoppingcart/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,22 +380,22 @@ def send_confirmation_emails(self, orderitems, is_order_type_business, csv_file,
for recipient in recipient_list:
email_context = {
'order': self,
'recipient_name': recipient[0],
'recipient_type': recipient[2],
'site_name': site_name,
'order_items': orderitems,
'course_names': ", ".join(course_names),
'dashboard_url': dashboard_url,
'currency_symbol': settings.PAID_COURSE_REGISTRATION_CURRENCY[1],
'order_placed_by': '{username} ({email})'.format(
username=self.user.username, email=self.user.email
),
'has_billing_info': settings.FEATURES['STORE_BILLING_INFO'],
'platform_name': configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME),
'payment_support_email': configuration_helpers.get_value(
'payment_support_email', settings.PAYMENT_SUPPORT_EMAIL,
),
'payment_email_signature': configuration_helpers.get_value('payment_email_signature'),
'recipient_name': recipient[0],
'recipient_type': recipient[2],
'site_name': site_name,
'order_items': orderitems,
'course_names': ", ".join(course_names),
'dashboard_url': dashboard_url,
'currency_symbol': settings.PAID_COURSE_REGISTRATION_CURRENCY[1],
'order_placed_by': '{username} ({email})'.format(
username=self.user.username, email=self.user.email
),
'has_billing_info': settings.FEATURES['STORE_BILLING_INFO'],
'platform_name': configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME),
'payment_support_email': configuration_helpers.get_value(
'payment_support_email', settings.PAYMENT_SUPPORT_EMAIL,
),
'payment_email_signature': configuration_helpers.get_value('payment_email_signature'),
}
message = render_to_string(
'emails/business_order_confirmation_email.txt' if is_order_type_business else 'emails/order_confirmation_email.txt',
Expand Down
1 change: 0 additions & 1 deletion lms/envs/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,4 +918,3 @@
ORA2_FILEUPLOAD_ROOT = ENV_TOKENS.get('ORA2_FILEUPLOAD_ROOT', ORA2_FILEUPLOAD_ROOT)
SEARCH_SKIP_ENROLLMENT_START_DATE_FILTERING = FEATURES.get("SEARCH_SKIP_ENROLLMENT_START_DATE_FILTERING", True)
#### RaccoonGang ####

1 change: 0 additions & 1 deletion lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3041,4 +3041,3 @@
############## Settings for the Enterprise App ######################

ENTERPRISE_ENROLLMENT_API_URL = LMS_ROOT_URL + "/api/enrollment/v1/"

2 changes: 1 addition & 1 deletion lms/envs/static_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

EDX_PLATFORM_STATIC_ROOT_BASE = settings.STATIC_ROOT_BASE

STATIC_ROOT_BASE=os.environ.get('STATIC_COLLECTOR_ROOT', '/edx/var/edxapp/static_collector')
STATIC_ROOT_BASE = os.environ.get('STATIC_COLLECTOR_ROOT', '/edx/var/edxapp/static_collector')
STATIC_ROOT = path(STATIC_ROOT_BASE)
3 changes: 1 addition & 2 deletions openedx/core/djangoapps/dark_lang/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,11 @@ def process_request(self, request):
if not DarkLangConfig.current().enabled:
return

reload(sys)
reload(sys)
sys.setdefaultencoding('utf8')

language = translation.get_language_from_request(request)
try:
locale.setlocale(locale.LC_ALL, settings.LOCALESET_FROM_REQUEST.get(language))
except:
pass

1 change: 1 addition & 0 deletions openedx/core/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from storages.backends.azure_storage import AzureStorage
from azure.storage import AccessPolicy, SharedAccessPolicy


class ProductionStorage(
PipelineForgivingStorage,
OptimizedFilesMixin,
Expand Down
13 changes: 8 additions & 5 deletions pavelib/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from openedx.core.djangoapps.theming.paver_helpers import get_theme_paths

from pwd import getpwnam
from pwd import getpwnam

from django.core.wsgi import get_wsgi_application
from django.conf import settings as django_settings
Expand Down Expand Up @@ -83,9 +83,11 @@
# Collectstatic log directory setting
COLLECTSTATIC_LOG_DIR_ARG = "collect_log_dir"


def get_static_collector_root():
return os.environ.get('STATIC_COLLECTOR_ROOT', '/edx/var/edxapp/static_collector')


def get_sass_directories(system, theme_dir=None):
"""
Determine the set of SASS directories to be compiled for the specified list of system and theme
Expand Down Expand Up @@ -663,6 +665,7 @@ def collect_assets(systems, settings, **kwargs):
)))
print("\t\tFinished collecting {} assets.".format(sys))


def _collect_assets_cmd(system, **kwargs):
"""
Returns the collecstatic command to be used for the given system
Expand Down Expand Up @@ -783,6 +786,7 @@ def watch_assets(options):
observer.stop()
print("\nStopped asset watcher.")


@task
@needs(
'pavelib.prereqs.install_node_prereqs',
Expand Down Expand Up @@ -837,20 +841,19 @@ def update_assets(args):
if args.system[0] == 'studio':
current_sys = 'cms'

os.environ.setdefault("SERVICE_VARIANT","{sys}".format(sys=current_sys))
os.environ.setdefault("SERVICE_VARIANT", "{sys}".format(sys=current_sys))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{sys}.envs.static_collector".format(sys=current_sys))

application = get_wsgi_application() # pylint: disable=invalid-name

if hasattr(django_settings, 'STATIC_COLLECTOR_ROOT'):
STATIC_COLLECTOR_ROOT = django_settings.STATIC_COLLECTOR_ROOT
else:
STATIC_COLLECTOR_ROOT= get_static_collector_root()
STATIC_COLLECTOR_ROOT = get_static_collector_root()

if not os.path.isdir(STATIC_COLLECTOR_ROOT):
os.mkdir(STATIC_COLLECTOR_ROOT)
print('\t\tDirectory "STATIC_COLLECTOR_ROOT" has been created to store '
' static files.')
print('\t\tDirectory "STATIC_COLLECTOR_ROOT" has been created to store static files.')

process_xmodule_assets()
process_npm_assets()
Expand Down
3 changes: 3 additions & 0 deletions requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ edx-ccx-keys==0.2.1
edx-drf-extensions==1.2.2
edx-i18n-tools==0.3.7
edx-lint==0.4.3
# astroid 1.3.8 is an unmet dependency of the version of pylint used in edx-lint 0.4.3
# when upgrading edx-lint, we should try to remove this from the platform
astroid==1.3.8
edx-django-oauth2-provider==1.1.4
edx-django-sites-extensions==2.1.1
edx-enterprise==0.9.0
Expand Down
3 changes: 2 additions & 1 deletion scripts/generic-ci-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ set -e
# or else no tests will be executed.
SHARD=${SHARD:="all"}
NUMBER_OF_BOKCHOY_THREADS=${NUMBER_OF_BOKCHOY_THREADS:=1}
TARGET_BRANCH=${TARGET_BRANCH:="origin/master"}

# Clean up previous builds
git clean -qxfd
Expand Down Expand Up @@ -90,7 +91,7 @@ case "$TEST_SUITE" in
paver run_safecommit_report > safecommit.log || { cat safecommit.log; EXIT=1; }
# Run quality task. Pass in the 'fail-under' percentage to diff-quality
echo "Running diff quality."
paver run_quality -p 100 || EXIT=1
paver run_quality -p 100 -b $TARGET_BRANCH|| EXIT=1

# Need to create an empty test result so the post-build
# action doesn't fail the build.
Expand Down