Commit 9a52a17a by Vik Paruchuri

Merge remote-tracking branch 'origin/master' into feature/vik/oe-editor

parents fd6da08a 747dec07
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
This config file extends the test environment configuration This config file extends the test environment configuration
so that we can run the lettuce acceptance tests. so that we can run the lettuce acceptance tests.
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .test import * from .test import *
# You need to start the server in debug mode, # You need to start the server in debug mode,
......
""" """
This is the default template for our main set of AWS servers. This is the default template for our main set of AWS servers.
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
import json import json
from .common import * from .common import *
......
...@@ -19,6 +19,10 @@ Longer TODO: ...@@ -19,6 +19,10 @@ Longer TODO:
multiple sites, but we do need a way to map their data assets. multiple sites, but we do need a way to map their data assets.
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
import sys import sys
import lms.envs.common import lms.envs.common
from path import path from path import path
......
""" """
This config file runs the simplest dev environment""" This config file runs the simplest dev environment"""
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .common import * from .common import *
from logsettings import get_logger_config from logsettings import get_logger_config
......
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
# dev environment for ichuang/mit # dev environment for ichuang/mit
# FORCE_SCRIPT_NAME = '/cms' # FORCE_SCRIPT_NAME = '/cms'
......
...@@ -8,6 +8,10 @@ The worker can be executed using: ...@@ -8,6 +8,10 @@ The worker can be executed using:
django_admin.py celery worker django_admin.py celery worker
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from dev import * from dev import *
################################# CELERY ###################################### ################################# CELERY ######################################
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
This configuration is used for running jasmine tests This configuration is used for running jasmine tests
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .test import * from .test import *
from logsettings import get_logger_config from logsettings import get_logger_config
......
...@@ -7,6 +7,11 @@ sessions. Assumes structure: ...@@ -7,6 +7,11 @@ sessions. Assumes structure:
/mitx # The location of this repo /mitx # The location of this repo
/log # Where we're going to write log files /log # Where we're going to write log files
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .common import * from .common import *
import os import os
from path import path from path import path
......
...@@ -5,6 +5,12 @@ ...@@ -5,6 +5,12 @@
// talbs: we need to slowly ween ourselves off of these // talbs: we need to slowly ween ourselves off of these
// ==================== // ====================
// line-height (old way)
@function lh($amount: 1) {
@return $body-line-height * $amount;
}
// inherited - vertical and horizontal centering // inherited - vertical and horizontal centering
@mixin vertically-and-horizontally-centered ($height, $width) { @mixin vertically-and-horizontally-centered ($height, $width) {
left: 50%; left: 50%;
......
...@@ -11,54 +11,54 @@ ...@@ -11,54 +11,54 @@
.t-title1 { .t-title1 {
@extend .t-title; @extend .t-title;
@include font-size(60); @include font-size(60);
@include lh(60); @include line-height(60);
} }
.t-title2 { .t-title2 {
@extend .t-title; @extend .t-title;
@include font-size(48); @include font-size(48);
@include lh(48); @include line-height(48);
} }
.t-title3 { .t-title3 {
@include font-size(36); @include font-size(36);
@include lh(36); @include line-height(36);
} }
.t-title4 { .t-title4 {
@extend .t-title; @extend .t-title;
@include font-size(24); @include font-size(24);
@include lh(24); @include line-height(24);
} }
.t-title5 { .t-title5 {
@extend .t-title; @extend .t-title;
@include font-size(18); @include font-size(18);
@include lh(18); @include line-height(18);
} }
.t-title6 { .t-title6 {
@extend .t-title; @extend .t-title;
@include font-size(16); @include font-size(16);
@include lh(16); @include line-height(16);
} }
.t-title7 { .t-title7 {
@extend .t-title; @extend .t-title;
@include font-size(14); @include font-size(14);
@include lh(14); @include line-height(14);
} }
.t-title8 { .t-title8 {
@extend .t-title; @extend .t-title;
@include font-size(12); @include font-size(12);
@include lh(12); @include line-height(12);
} }
.t-title9 { .t-title9 {
@extend .t-title; @extend .t-title;
@include font-size(11); @include font-size(11);
@include lh(11); @include line-height(11);
} }
// ==================== // ====================
...@@ -71,31 +71,31 @@ ...@@ -71,31 +71,31 @@
.t-copy-base { .t-copy-base {
@extend .t-copy; @extend .t-copy;
@include font-size(16); @include font-size(16);
@include lh(16); @include line-height(16);
} }
.t-copy-lead1 { .t-copy-lead1 {
@extend .t-copy; @extend .t-copy;
@include font-size(18); @include font-size(18);
@include lh(18); @include line-height(18);
} }
.t-copy-lead2 { .t-copy-lead2 {
@extend .t-copy; @extend .t-copy;
@include font-size(24); @include font-size(24);
@include lh(24); @include line-height(24);
} }
.t-copy-sub1 { .t-copy-sub1 {
@extend .t-copy; @extend .t-copy;
@include font-size(14); @include font-size(14);
@include lh(14); @include line-height(14);
} }
.t-copy-sub2 { .t-copy-sub2 {
@extend .t-copy; @extend .t-copy;
@include font-size(12); @include font-size(12);
@include lh(12); @include line-height(12);
} }
// ==================== // ====================
...@@ -103,22 +103,22 @@ ...@@ -103,22 +103,22 @@
// actions/labels // actions/labels
.t-action1 { .t-action1 {
@include font-size(18); @include font-size(18);
@include lh(18); @include line-height(18);
} }
.t-action2 { .t-action2 {
@include font-size(16); @include font-size(16);
@include lh(16); @include line-height(16);
} }
.t-action3 { .t-action3 {
@include font-size(14); @include font-size(14);
@include lh(14); @include line-height(14);
} }
.t-action4 { .t-action4 {
@include font-size(12); @include font-size(12);
@include lh(12); @include line-height(12);
} }
......
...@@ -39,6 +39,9 @@ class TestLazyMod(unittest.TestCase): ...@@ -39,6 +39,9 @@ class TestLazyMod(unittest.TestCase):
self.assertEqual(hsv[0], 0.25) self.assertEqual(hsv[0], 0.25)
def test_dotted(self): def test_dotted(self):
self.assertNotIn("email.utils", sys.modules) # wsgiref is a module with submodules that is not already imported.
email_utils = LazyModule("email.utils") # Any similar module would do. This test demonstrates that the module
self.assertEqual(email_utils.quote('"hi"'), r'\"hi\"') # is not already im
self.assertNotIn("wsgiref.util", sys.modules)
wsgiref_util = LazyModule("wsgiref.util")
self.assertEqual(wsgiref_util.guess_scheme({}), "http")
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
} }
// mixins - line height // mixins - line height
@mixin lh($fontSize: auto){ @mixin line-height($fontSize: auto){
line-height: ($fontSize*1.48) + px; line-height: ($fontSize*1.48) + px;
line-height: (($fontSize/10)*1.48) + rem; line-height: (($fontSize/10)*1.48) + rem;
} }
......
...@@ -174,6 +174,9 @@ def forum_form_discussion(request, course_id): ...@@ -174,6 +174,9 @@ def forum_form_discussion(request, course_id):
try: try:
unsafethreads, query_params = get_threads(request, course_id) # This might process a search query unsafethreads, query_params = get_threads(request, course_id) # This might process a search query
threads = [utils.safe_content(thread) for thread in unsafethreads] threads = [utils.safe_content(thread) for thread in unsafethreads]
except (cc.utils.CommentClientMaintenanceError) as err:
log.warning("Forum is in maintenance mode")
return render_to_response('discussion/maintenance.html', {})
except (cc.utils.CommentClientError, cc.utils.CommentClientUnknownError) as err: except (cc.utils.CommentClientError, cc.utils.CommentClientUnknownError) as err:
log.error("Error loading forum discussion threads: %s" % str(err)) log.error("Error loading forum discussion threads: %s" % str(err))
raise Http404 raise Http404
......
...@@ -13,7 +13,7 @@ class Migration(SchemaMigration): ...@@ -13,7 +13,7 @@ class Migration(SchemaMigration):
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),
('course_id', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)), ('course_id', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)),
('uri', self.gf('django.db.models.fields.CharField')(max_length=512, db_index=True)), ('uri', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)),
('text', self.gf('django.db.models.fields.TextField')(default='')), ('text', self.gf('django.db.models.fields.TextField')(default='')),
('quote', self.gf('django.db.models.fields.TextField')(default='')), ('quote', self.gf('django.db.models.fields.TextField')(default='')),
('range_start', self.gf('django.db.models.fields.CharField')(max_length=2048)), ('range_start', self.gf('django.db.models.fields.CharField')(max_length=2048)),
...@@ -82,7 +82,7 @@ class Migration(SchemaMigration): ...@@ -82,7 +82,7 @@ class Migration(SchemaMigration):
'tags': ('django.db.models.fields.TextField', [], {'default': "''"}), 'tags': ('django.db.models.fields.TextField', [], {'default': "''"}),
'text': ('django.db.models.fields.TextField', [], {'default': "''"}), 'text': ('django.db.models.fields.TextField', [], {'default': "''"}),
'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}), 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}),
'uri': ('django.db.models.fields.CharField', [], {'max_length': '512', 'db_index': 'True'}), 'uri': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
} }
} }
......
...@@ -9,7 +9,7 @@ import json ...@@ -9,7 +9,7 @@ import json
class Note(models.Model): class Note(models.Model):
user = models.ForeignKey(User, db_index=True) user = models.ForeignKey(User, db_index=True)
course_id = models.CharField(max_length=255, db_index=True) course_id = models.CharField(max_length=255, db_index=True)
uri = models.CharField(max_length=512, db_index=True) uri = models.CharField(max_length=255, db_index=True)
text = models.TextField(default="") text = models.TextField(default="")
quote = models.TextField(default="") quote = models.TextField(default="")
range_start = models.CharField(max_length=2048) # xpath string range_start = models.CharField(max_length=2048) # xpath string
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
This config file extends the test environment configuration This config file extends the test environment configuration
so that we can run the lettuce acceptance tests. so that we can run the lettuce acceptance tests.
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .test import * from .test import *
# You need to start the server in debug mode, # You need to start the server in debug mode,
......
...@@ -6,6 +6,11 @@ Common traits: ...@@ -6,6 +6,11 @@ Common traits:
* Use memcached, and cache-backed sessions * Use memcached, and cache-backed sessions
* Use a MySQL 5.1 database * Use a MySQL 5.1 database
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
import json import json
from .common import * from .common import *
......
...@@ -3,6 +3,11 @@ This config file is a copy of dev environment without the Debug ...@@ -3,6 +3,11 @@ This config file is a copy of dev environment without the Debug
Toolbar. I it suitable to run against acceptance tests. Toolbar. I it suitable to run against acceptance tests.
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .dev import * from .dev import *
# REMOVE DEBUG TOOLBAR # REMOVE DEBUG TOOLBAR
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
Settings for the LMS that runs alongside the CMS on AWS Settings for the LMS that runs alongside the CMS on AWS
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from ..aws import * from ..aws import *
with open(ENV_ROOT / "cms.auth.json") as auth_file: with open(ENV_ROOT / "cms.auth.json") as auth_file:
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
Settings for the LMS that runs alongside the CMS on AWS Settings for the LMS that runs alongside the CMS on AWS
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from ..dev import * from ..dev import *
MITX_FEATURES['AUTH_USE_MIT_CERTIFICATES'] = False MITX_FEATURES['AUTH_USE_MIT_CERTIFICATES'] = False
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
Settings for the LMS that runs alongside the CMS on AWS Settings for the LMS that runs alongside the CMS on AWS
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .dev import * from .dev import *
MODULESTORE = { MODULESTORE = {
......
...@@ -18,6 +18,11 @@ Longer TODO: ...@@ -18,6 +18,11 @@ Longer TODO:
3. We need to handle configuration for multiple courses. This could be as 3. We need to handle configuration for multiple courses. This could be as
multiple sites, but we do need a way to map their data assets. multiple sites, but we do need a way to map their data assets.
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
import sys import sys
import os import os
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
These are debug machines used for content creators, so they're kind of a cross These are debug machines used for content creators, so they're kind of a cross
between dev machines and AWS machines. between dev machines and AWS machines.
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .aws import * from .aws import *
DEBUG = True DEBUG = True
......
...@@ -7,6 +7,11 @@ sessions. Assumes structure: ...@@ -7,6 +7,11 @@ sessions. Assumes structure:
/mitx # The location of this repo /mitx # The location of this repo
/log # Where we're going to write log files /log # Where we're going to write log files
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .common import * from .common import *
from logsettings import get_logger_config from logsettings import get_logger_config
......
...@@ -8,6 +8,10 @@ sessions. Assumes structure: ...@@ -8,6 +8,10 @@ sessions. Assumes structure:
/log # Where we're going to write log files /log # Where we're going to write log files
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
import socket import socket
if 'eecs1' in socket.gethostname(): if 'eecs1' in socket.gethostname():
......
...@@ -7,6 +7,11 @@ sessions. Assumes structure: ...@@ -7,6 +7,11 @@ sessions. Assumes structure:
/mitx # The location of this repo /mitx # The location of this repo
/log # Where we're going to write log files /log # Where we're going to write log files
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .common import * from .common import *
from logsettings import get_logger_config from logsettings import get_logger_config
from .dev import * from .dev import *
......
...@@ -9,6 +9,11 @@ following domains to 127.0.0.1 in your /etc/hosts file: ...@@ -9,6 +9,11 @@ following domains to 127.0.0.1 in your /etc/hosts file:
Note that OS X has a bug where using *.local domains is excruciatingly slow, so Note that OS X has a bug where using *.local domains is excruciatingly slow, so
use *.dev domains instead for local testing. use *.dev domains instead for local testing.
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .dev import * from .dev import *
MITX_FEATURES['SUBDOMAIN_COURSE_LISTINGS'] = True MITX_FEATURES['SUBDOMAIN_COURSE_LISTINGS'] = True
......
""" """
This config file runs the dev environment, but with mongo as the datastore This config file runs the dev environment, but with mongo as the datastore
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .dev import * from .dev import *
GITHUB_REPO_ROOT = ENV_ROOT / "data" GITHUB_REPO_ROOT = ENV_ROOT / "data"
......
...@@ -8,6 +8,10 @@ The worker can be executed using: ...@@ -8,6 +8,10 @@ The worker can be executed using:
django_admin.py celery worker django_admin.py celery worker
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from dev import * from dev import *
################################# CELERY ###################################### ################################# CELERY ######################################
......
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from ..dev import * from ..dev import *
CLASSES_TO_DBS = { CLASSES_TO_DBS = {
......
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .courses import * from .courses import *
DATABASES = course_db_for('HarvardX/CS50x/2012') DATABASES = course_db_for('HarvardX/CS50x/2012')
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .courses import * from .courses import *
DATABASES = course_db_for('MITx/6.002x/2012_Fall') DATABASES = course_db_for('MITx/6.002x/2012_Fall')
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
Note that for this to work at all, you must have memcached running (or you won't Note that for this to work at all, you must have memcached running (or you won't
get shared sessions) get shared sessions)
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from courses import * from courses import *
# Move this to a shared file later: # Move this to a shared file later:
......
...@@ -13,6 +13,11 @@ Dir structure: ...@@ -13,6 +13,11 @@ Dir structure:
/log # Where we're going to write log files /log # Where we're going to write log files
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .dev import * from .dev import *
WIKI_ENABLED = True WIKI_ENABLED = True
......
# We intentionally define variables that aren't used
# pylint: disable=W0614
DISCUSSION_ALLOWED_UPLOAD_FILE_TYPES = ('.jpg', '.jpeg', '.gif', '.bmp', '.png', '.tiff') DISCUSSION_ALLOWED_UPLOAD_FILE_TYPES = ('.jpg', '.jpeg', '.gif', '.bmp', '.png', '.tiff')
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
# Settings for edx4edx production instance # Settings for edx4edx production instance
from .aws import * from .aws import *
COURSE_NAME = "edx4edx" COURSE_NAME = "edx4edx"
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
This configuration is used for running jasmine tests This configuration is used for running jasmine tests
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .test import * from .test import *
from logsettings import get_logger_config from logsettings import get_logger_config
......
...@@ -7,6 +7,11 @@ sessions. Assumes structure: ...@@ -7,6 +7,11 @@ sessions. Assumes structure:
/mitx # The location of this repo /mitx # The location of this repo
/log # Where we're going to write log files /log # Where we're going to write log files
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .common import * from .common import *
from logsettings import get_logger_config from logsettings import get_logger_config
......
...@@ -7,6 +7,11 @@ sessions. Assumes structure: ...@@ -7,6 +7,11 @@ sessions. Assumes structure:
/mitx # The location of this repo /mitx # The location of this repo
/log # Where we're going to write log files /log # Where we're going to write log files
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .common import * from .common import *
import os import os
from path import path from path import path
......
...@@ -7,6 +7,11 @@ sessions. Assumes structure: ...@@ -7,6 +7,11 @@ sessions. Assumes structure:
/mitx # The location of this repo /mitx # The location of this repo
/log # Where we're going to write log files /log # Where we're going to write log files
""" """
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .common import * from .common import *
from logsettings import get_logger_config from logsettings import get_logger_config
import os import os
......
...@@ -55,6 +55,9 @@ def perform_request(method, url, data_or_params=None, *args, **kwargs): ...@@ -55,6 +55,9 @@ def perform_request(method, url, data_or_params=None, *args, **kwargs):
if 200 < response.status_code < 500: if 200 < response.status_code < 500:
raise CommentClientError(response.text) raise CommentClientError(response.text)
# Heroku returns a 503 when an application is in maintenance mode
elif response.status_code == 503:
raise CommentClientMaintenanceError(response.text)
elif response.status_code == 500: elif response.status_code == 500:
raise CommentClientUnknownError(response.text) raise CommentClientUnknownError(response.text)
else: else:
...@@ -72,5 +75,9 @@ class CommentClientError(Exception): ...@@ -72,5 +75,9 @@ class CommentClientError(Exception):
return repr(self.message) return repr(self.message)
class CommentClientMaintenanceError(CommentClientError):
pass
class CommentClientUnknownError(CommentClientError): class CommentClientUnknownError(CommentClientError):
pass pass
<%inherit file="../main.html" />
<h1>We're sorry</h1>
<p>The forums are currently undergoing maintenance. We'll have them back up shortly!</p>
...@@ -14,16 +14,31 @@ def report_dir_path(dir) ...@@ -14,16 +14,31 @@ def report_dir_path(dir)
return File.join(REPORT_DIR, dir.to_s) return File.join(REPORT_DIR, dir.to_s)
end end
def when_changed(unchanged_message, *files) def compute_fingerprint(files, dirs)
Rake::Task[PREREQS_MD5_DIR].invoke
cache_file = File.join(PREREQS_MD5_DIR, files.join('-').gsub(/\W+/, '-')) + '.md5'
digest = Digest::MD5.new() digest = Digest::MD5.new()
# Digest the contents of all the files.
Dir[*files].select{|file| File.file?(file)}.each do |file| Dir[*files].select{|file| File.file?(file)}.each do |file|
digest.file(file) digest.file(file)
end end
if !File.exists?(cache_file) or digest.hexdigest != File.read(cache_file)
# Digest the names of the files in all the dirs.
dirs.each do |dir|
file_names = Dir.entries(dir).sort.join(" ")
digest.update(file_names)
end
digest.hexdigest
end
# Hash the contents of all the files, and the names of files in the dirs.
# Run the block if they've changed.
def when_changed(unchanged_message, files, dirs=[])
Rake::Task[PREREQS_MD5_DIR].invoke
cache_file = File.join(PREREQS_MD5_DIR, files[0].gsub(/\W+/, '-').sub(/-+$/, '')) + '.md5'
if !File.exists?(cache_file) or compute_fingerprint(files, dirs) != File.read(cache_file)
yield yield
File.write(cache_file, digest.hexdigest) File.write(cache_file, compute_fingerprint(files, dirs))
elsif !unchanged_message.empty? elsif !unchanged_message.empty?
puts unchanged_message puts unchanged_message
end end
......
require './rakefiles/helpers.rb' require './rakefiles/helpers.rb'
PREREQS_MD5_DIR = ENV["PREREQ_CACHE_DIR"] || File.join(REPO_ROOT, '.prereqs_cache') PREREQS_MD5_DIR = ENV["PREREQ_CACHE_DIR"] || File.join(REPO_ROOT, '.prereqs_cache')
CLOBBER.include(PREREQS_MD5_DIR) CLOBBER.include(PREREQS_MD5_DIR)
...@@ -13,7 +12,7 @@ task :install_prereqs => [:install_node_prereqs, :install_ruby_prereqs, :install ...@@ -13,7 +12,7 @@ task :install_prereqs => [:install_node_prereqs, :install_ruby_prereqs, :install
desc "Install all node prerequisites for the lms and cms" desc "Install all node prerequisites for the lms and cms"
task :install_node_prereqs => "ws:migrate" do task :install_node_prereqs => "ws:migrate" do
unchanged = 'Node requirements unchanged, nothing to install' unchanged = 'Node requirements unchanged, nothing to install'
when_changed(unchanged, 'package.json') do when_changed(unchanged, ['package.json']) do
sh('npm install') sh('npm install')
end unless ENV['NO_PREREQ_INSTALL'] end unless ENV['NO_PREREQ_INSTALL']
end end
...@@ -21,20 +20,21 @@ end ...@@ -21,20 +20,21 @@ end
desc "Install all ruby prerequisites for the lms and cms" desc "Install all ruby prerequisites for the lms and cms"
task :install_ruby_prereqs => "ws:migrate" do task :install_ruby_prereqs => "ws:migrate" do
unchanged = 'Ruby requirements unchanged, nothing to install' unchanged = 'Ruby requirements unchanged, nothing to install'
when_changed(unchanged, 'Gemfile') do when_changed(unchanged, ['Gemfile']) do
sh('bundle install') sh('bundle install')
end unless ENV['NO_PREREQ_INSTALL'] end unless ENV['NO_PREREQ_INSTALL']
end end
desc "Install all python prerequisites for the lms and cms" desc "Install all python prerequisites for the lms and cms"
task :install_python_prereqs => "ws:migrate" do task :install_python_prereqs => "ws:migrate" do
site_packages_dir = `python -c 'import os; import distutils.sysconfig as dusc; print dusc.get_python_lib()'`.chomp
unchanged = 'Python requirements unchanged, nothing to install' unchanged = 'Python requirements unchanged, nothing to install'
when_changed(unchanged, 'requirements/**/*') do when_changed(unchanged, ['requirements/**/*'], [site_packages_dir]) do
ENV['PIP_DOWNLOAD_CACHE'] ||= '.pip_download_cache' ENV['PIP_DOWNLOAD_CACHE'] ||= '.pip_download_cache'
sh('pip install --exists-action w -r requirements/edx/base.txt') sh('pip install --exists-action w -r requirements/edx/base.txt')
sh('pip install --exists-action w -r requirements/edx/post.txt') sh('pip install --exists-action w -r requirements/edx/post.txt')
# Check for private-requirements.txt: used to install our libs as working dirs, # requirements/private.txt is used to install our libs as
# or personal-use tools. # working dirs, or for personal-use tools.
if File.file?("requirements/private.txt") if File.file?("requirements/private.txt")
sh('pip install -r requirements/private.txt') sh('pip install -r requirements/private.txt')
end end
......
def run_pylint(system, report_dir, flags='')
apps = Dir["#{system}", "#{system}/djangoapps/*", "#{system}/lib/*"].map do |app|
File.basename(app)
end.select do |app|
app !=~ /.pyc$/
end.map do |app|
if app =~ /.py$/
app.gsub('.py', '')
else
app
end
end
pythonpath_prefix = "PYTHONPATH=#{system}:#{system}/djangoapps:#{system}/lib:common/djangoapps:common/lib"
sh("#{pythonpath_prefix} pylint #{flags} -f parseable #{apps.join(' ')} | tee #{report_dir}/pylint.report")
end
[:lms, :cms, :common].each do |system| [:lms, :cms, :common].each do |system|
report_dir = report_dir_path(system) report_dir = report_dir_path(system)
...@@ -11,21 +28,18 @@ ...@@ -11,21 +28,18 @@
desc "Run pylint on all #{system} code" desc "Run pylint on all #{system} code"
task "pylint_#{system}" => [report_dir, :install_python_prereqs] do task "pylint_#{system}" => [report_dir, :install_python_prereqs] do
apps = Dir["#{system}/*.py", "#{system}/djangoapps/*", "#{system}/lib/*"].map do |app| run_pylint(system, report_dir)
File.basename(app) end
end.select do |app| namespace "pylint_#{system}" do
app !=~ /.pyc$/ desc "Run pylint checking for errors only, and aborting if there are any"
end.map do |app| task :errors do
if app =~ /.py$/ run_pylint(system, report_dir, '-E')
app.gsub('.py', '')
else
app
end
end end
pythonpath_prefix = "PYTHONPATH=#{system}:#{system}/djangoapps:#{system}/lib:common/djangoapps:common/lib"
sh("#{pythonpath_prefix} pylint --rcfile=.pylintrc -f parseable #{apps.join(' ')} | tee #{report_dir}/pylint.report")
end end
namespace :pylint do
task :errors => "pylint_#{system}:errors"
end
task :pylint => "pylint_#{system}" task :pylint => "pylint_#{system}"
end end
\ No newline at end of file
...@@ -74,6 +74,7 @@ lettuce==0.2.16 ...@@ -74,6 +74,7 @@ lettuce==0.2.16
mock==0.8.0 mock==0.8.0
nosexcover==1.0.7 nosexcover==1.0.7
pep8==1.4.5 pep8==1.4.5
pylint==0.28
rednose==0.3 rednose==0.3
selenium==2.31.0 selenium==2.31.0
splinter==0.5.0 splinter==0.5.0
...@@ -81,7 +82,3 @@ django_nose==1.1 ...@@ -81,7 +82,3 @@ django_nose==1.1
django-jasmine==0.3.2 django-jasmine==0.3.2
django_debug_toolbar django_debug_toolbar
django-debug-toolbar-mongo django-debug-toolbar-mongo
# Install pylint from a specific commit on trunk
# to get the fix for this issue: http://www.logilab.org/ticket/122793
https://bitbucket.org/logilab/pylint/get/e828cb5.zip
...@@ -8,5 +8,5 @@ ...@@ -8,5 +8,5 @@
-e git://github.com/eventbrite/zendesk.git@d53fe0e81b623f084e91776bcf6369f8b7b63879#egg=zendesk -e git://github.com/eventbrite/zendesk.git@d53fe0e81b623f084e91776bcf6369f8b7b63879#egg=zendesk
# Our libraries: # Our libraries:
-e git+https://github.com/edx/XBlock.git@483e0cb1#egg=XBlock -e git+https://github.com/edx/XBlock.git@2144a25d#egg=XBlock
-e git+https://github.com/edx/codejail.git@07494f1#egg=codejail -e git+https://github.com/edx/codejail.git@07494f1#egg=codejail
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment