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

central-develop into 0.17.x #5595

Merged
Merged
Show file tree
Hide file tree
Changes from 132 commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
95ae21e
Student should be redirected to login page if he/she gets looged out …
anuragkanungo Feb 4, 2015
0615773
Merge pull request #2939 from anuragkanungo/nalanda-rct3
aronasorman Feb 4, 2015
3daac46
Added Unit Variable to ExerciseLog Export
anuragkanungo Feb 7, 2015
30758b4
Updated code for unit variable in exercise log
anuragkanungo Feb 7, 2015
5d6a29d
Increased height of exercise name column in exam reports
anuragkanungo Feb 10, 2015
6d7e510
Added Exam Prep Playlists
anuragkanungo Feb 10, 2015
0cef1b9
Added student_testing/data/407.json
anuragkanungo Feb 10, 2015
6c70ea7
Added 15Nov2014 RCT condition check for unit variable
anuragkanungo Feb 10, 2015
8fea95e
Merge pull request #3016 from anuragkanungo/smps_4b_exam_results
aronasorman Feb 10, 2015
318a01a
Merge pull request #3011 from anuragkanungo/exam_topic_width
aronasorman Feb 10, 2015
bf146dc
Merge pull request #3012 from anuragkanungo/playlist
aronasorman Feb 10, 2015
c6402d3
Added Student Mastery/Class Mastery CoachReports
anuragkanungo Feb 11, 2015
c1abb70
RCT Unit Variable comment
anuragkanungo Feb 11, 2015
5105876
Removed Unit Selection Box and Added Class Level Mastery
anuragkanungo Feb 12, 2015
6e6c0f0
correct unit for those we are sure else unit 0
anuragkanungo Feb 12, 2015
26592ee
Added comment why to keep unit variable as 0 for some cases
anuragkanungo Feb 12, 2015
61fb56b
Merge pull request #2958 from anuragkanungo/nalanda-rct3
jamalex Feb 12, 2015
5286833
Code cleanup and renamed report view to exercise_mastery_view
anuragkanungo Feb 13, 2015
af8d016
On Facility Switch remove playlist values from url, to avoid get exer…
anuragkanungo Feb 13, 2015
350a7f5
Fixed minor bugs related to division by zero and exercise selection
anuragkanungo Feb 13, 2015
1c582c2
Moved jquery.js required for dyna-tree persistance to static-libraries
anuragkanungo Feb 13, 2015
66a0248
Refactoring and percentage in float
anuragkanungo Feb 13, 2015
c106ca1
removed extra comma, tests was failing
anuragkanungo Feb 13, 2015
8e5e8e5
Merge pull request #3033 from anuragkanungo/coach_reports
jamalex Feb 20, 2015
bc21a36
Fix 3040, Redirect to login page in case of Unauthorized
anuragkanungo Feb 23, 2015
3bffde5
Used SetGetParam for url
anuragkanungo Feb 24, 2015
5e0b016
Test for redirect unauthorized playlist view request to login page
anuragkanungo Feb 24, 2015
d4c91a2
Added test for unauthorized request to redirect to login page
anuragkanungo Feb 24, 2015
cfb423d
Moved import to top
anuragkanungo Feb 24, 2015
14c8701
Added implicit wait for css selector to be found in selenium test
anuragkanungo Feb 24, 2015
b56a514
Updated implicit wait after selector
anuragkanungo Feb 24, 2015
4ffdb35
Increase implict wait timeout time
anuragkanungo Feb 24, 2015
7c9085b
Merge pull request #3092 from anuragkanungo/nalanda-rct3
aronasorman Feb 25, 2015
b68aadf
Fixing up loadtesting.
rtibbles Feb 27, 2015
618314d
Final tweaks and fixes for loadtesting.
rtibbles Feb 27, 2015
2c5cce4
Fixes up load_testing for nalanda_rct3
rtibbles Feb 27, 2015
b3f28a0
Adds description comment to loadtesting view.
rtibbles Feb 28, 2015
c06bab5
Merge pull request #3149 from rtibbles/load_testing_nalanda
jamalex Feb 28, 2015
dd65adb
Fixes video playback during loadtest
rtibbles Feb 28, 2015
0299599
Merge pull request #3161 from rtibbles/load_testing_video
jamalex Feb 28, 2015
e890a2d
Fixes exercise answering for nalanda-rct3
rtibbles Feb 28, 2015
b289d0f
Merge pull request #3163 from rtibbles/load_testing_video
jamalex Feb 28, 2015
54c23cb
Ignore content/khan folder in git.
jamalex Mar 1, 2015
1509abc
Re-enable motivational features by default for Nalanda.
jamalex Mar 1, 2015
0597547
Fixes and simplification to loadtesting app.
jamalex Mar 1, 2015
a6d62e5
Merge pull request #3165 from jamalex/loadtesting_fix
jamalex Mar 1, 2015
6e8da48
On loadtesting, set a timeout to continue even if page fails.
jamalex Mar 2, 2015
6177f63
Merge pull request #3169 from jamalex/loadtesting_robustness
rtibbles Mar 2, 2015
ee90bd5
when running an external kalite process, make sure we change the
aronasorman Mar 4, 2015
a5a5b1b
Skip unauthorzied redirect to login test on travis
anuragkanungo Mar 9, 2015
3bbd98e
Merge pull request #3198 from anuragkanungo/nalanda-rct3
anuragkanungo Mar 9, 2015
abb207c
Merge pull request #3200 from learningequality/nalanda-rct3
jamalex Mar 9, 2015
e6f34b2
Merge pull request #3156 from learningequality/develop
jamalex Mar 9, 2015
1f19654
Merge branch 'central-master' of github.com:learningequality/ka-lite …
jamalex Mar 9, 2015
2ebd3ed
Remove exercise_mastery_view.
jamalex Mar 9, 2015
097a747
Don't download assessment items when on central server.
jamalex Mar 9, 2015
073046f
add --no-assessment-download command for setup
aronasorman Mar 10, 2015
105272d
Merge pull request #3254 from jamalex/device_metadata_fix
jamalex Mar 11, 2015
e1d6c23
Cherry pick changes from develop
MCGallaspy Mar 16, 2015
63824f6
Fix js linting issue
MCGallaspy Mar 16, 2015
f13286c
Really fix device metadata issue (cherry pick from develop)
MCGallaspy Mar 17, 2015
c29c18d
Merge remote-tracking branch 'mcgallaspy/central-develop' into centra…
MCGallaspy Mar 17, 2015
645c7f0
Merge pull request #3309 from MCGallaspy/central-develop
aronasorman Mar 17, 2015
1648ace
Merge branch 'develop' into central-develop
aronasorman Mar 20, 2015
3755b72
Merge branch '0.13.x' into central-develop
aronasorman Mar 30, 2015
d24b7ab
fix the double-colons
aronasorman Mar 30, 2015
05bf1cd
make sure we're not the central server when checking for assessment i…
aronasorman Mar 31, 2015
3aaeea8
wrap unpack assessment item handling in settings.CENTRAL_SERVER state…
aronasorman Mar 31, 2015
5f82a77
Merge pull request #3454 from learningequality/0.13.x
aronasorman Apr 3, 2015
99dbcdb
Merge branch '0.13.x' into central-develop
Apr 6, 2015
c12f0ce
Merge pull request #3482 from jamalex/restore_response_count_to_its_f…
jamalex Apr 6, 2015
a276b0c
Additional diagnostic error data for bad client device import.
jamalex Apr 7, 2015
8a4d4be
Set the django module if given by kwargs.
Apr 7, 2015
f0bd27c
use CENTRAL_SERVER_URL instead of SECURESYNC_PROTOCOL +
Apr 7, 2015
34a27be
error out on registration when we get an invalid user error message.
Apr 7, 2015
65330fb
parse self.url.
Apr 7, 2015
eb670d5
Stop using deprecated command, update requirements, fix import
MCGallaspy Mar 31, 2015
8ffa4d2
use absolute path in kalitectl.py, update screenshot command
MCGallaspy Apr 1, 2015
ea857a6
Remove errant pdb.set_trace
MCGallaspy Apr 1, 2015
3ae33e7
Add language option to screenshots management command
MCGallaspy Apr 2, 2015
3510566
Fix language option on screenshot mgmt command
MCGallaspy Apr 2, 2015
3d273f2
Set up docs for translation. Need translated pofiles.
MCGallaspy Apr 2, 2015
ab8bc62
Don't build screenshots when making messages
MCGallaspy Apr 2, 2015
263e52b
Update README
MCGallaspy Apr 6, 2015
b0a9d48
Add dep for python 2.6
MCGallaspy Apr 7, 2015
83006de
Merge pull request #3490 from MCGallaspy/pick-docs-intl
aronasorman Apr 7, 2015
a253c1b
Merge pull request #3498 from learningequality/0.13.x
jamalex Apr 9, 2015
c3cc5ef
Merge pull request #3515 from jamalex/0.13-fixes
jamalex Apr 12, 2015
626f915
Merge branch 'develop' into central-develop
May 27, 2015
9801731
add missing import.
May 27, 2015
452e19e
Merge remote-tracking branch 'refs/remotes/u/develop' into central-de…
May 28, 2015
4d408f3
Merge branch 'develop' into central-develop
May 29, 2015
4771c3c
Merge branch 'develop' into central-develop
Jun 1, 2015
171f2f7
Merge branch '0.14.x' of github.com:learningequality/ka-lite into cen…
jamalex Jul 7, 2015
1c49921
Merge branch '0.14.x' of github.com:learningequality/ka-lite into cen…
jamalex Jul 7, 2015
de616c3
Merge branch 'tweaks_based_on_central_server' into central-develop
jamalex Jul 9, 2015
c682fa4
Merge pull request #4084 from jamalex/setup_fixes
jamalex Jul 11, 2015
5942943
Merge branch 'tweaks_based_on_central_server' of github.com:jamalex/k…
jamalex Jul 12, 2015
259d8ae
Merge branch '0.14.x' of github.com:learningequality/ka-lite into cen…
jamalex Jul 24, 2015
cabc30f
Merge branch '0.14.x' of github.com:learningequality/ka-lite into cen…
jamalex Jul 24, 2015
2a5fa54
Merge pull request #4161 from learningequality/0.14.x
jamalex Jul 25, 2015
590752e
Softload KHAN_ASSESSMENT_ITEM_DATABASE_PATH in case DB not defined.
jamalex Jul 27, 2015
1f87909
Merge pull request #4171 from jamalex/central_server_fixes
jamalex Jul 28, 2015
8adb6f3
Merge pull request #4207 from jamalex/securesync_fixes
jamalex Aug 5, 2015
68c6ffe
Merge pull request #4230 from rtibbles/zone_space_coach_reports
jamalex Aug 13, 2015
30f8bd1
Merge pull request #4236 from rtibbles/zone_space_coach_reports
jamalex Aug 13, 2015
6f62e04
Merge pull request #4243 from learningequality/0.14.x
jamalex Aug 15, 2015
41923fc
Safer BaseView.remove: remove el before reflow, no infinite recursion.
jamalex Aug 18, 2015
d6abcae
Merge pull request #4252 from jamalex/safer_removal_recursion_14
jamalex Aug 18, 2015
0c49a77
Merge pull request #4255 from jamalex/fix_container_overflow
jamalex Aug 18, 2015
fbc2912
Merge pull request #4279 from learningequality/0.14.x
aronasorman Aug 24, 2015
c01942e
Merge remote-tracking branch 'upstream/0.15.x' into central-develop
MCGallaspy Sep 18, 2015
719921a
Remove duplicate TestCase subclass
MCGallaspy Sep 18, 2015
361834b
Merge pull request #4455 from MCGallaspy/central-develop
MCGallaspy Sep 18, 2015
1323db0
Add get_cookie to base module & global scope
MCGallaspy Sep 21, 2015
cd4cb41
Do not use os-specific separator
MCGallaspy Sep 22, 2015
e418511
Massage the Popen arguments into windows form
MCGallaspy Sep 22, 2015
4951c10
Merge pull request #4465 from MCGallaspy/central-develop
rtibbles Sep 22, 2015
90d20c6
Merge pull request #4498 from MCGallaspy/central-develop
rtibbles Sep 24, 2015
d7cdc84
Merge pull request #4513 from learningequality/0.15.x
rtibbles Oct 8, 2015
dc56afc
Merge pull request #4683 from learningequality/0.15.x
aronasorman Nov 24, 2015
c789b22
Merge remote-tracking branch 'origin/0.16.x' into central-develop
aronasorman Mar 17, 2016
bf2cfa4
Merge pull request #5014 from learningequality/update-central-develop
jamalex Mar 21, 2016
cb25c26
Merge pull request #5034 from jamalex/pin_npm_versions
jamalex Mar 23, 2016
45cc3e4
Add options object to reference org_id from to ZoneSelectView in data…
rtibbles Apr 20, 2016
a118a2d
Merge pull request #5095 from rtibbles/central-develop-org-id
jamalex Apr 20, 2016
bdf518c
Remove .gitmodules file causing RTD to break
Nov 14, 2016
635c5ea
Remove unused submodule for RTD to build
Nov 16, 2016
a2b59b0
Make version visible in docs for installation guide - fixes #5165
Mar 16, 2017
3555f82
Merge tag '0.16.x' into central-develop
Jul 4, 2019
9272dcf
Merge remote-tracking branch 'upstream/0.16.x' into central-develop
Jul 4, 2019
3fccd47
Merge branch 'central-develop' into central-develop-into-0.17.x
Jul 15, 2019
a56efba
Remove duplicated line
Jul 15, 2019
54bc417
Remove unused JS and cherry-picked CSS from #3033
Jul 16, 2019
650a95d
Remove unused .json file from #3033
Jul 16, 2019
e554397
Remove Nalanda-specific code from #3033
Jul 16, 2019
338fc49
call_outside_command_with_output moved to central server
Jul 17, 2019
f2ae87c
Remove debug statement
Jul 17, 2019
5161c9b
Remove unreferenced JS library jquery.cookie.js
Sep 2, 2019
bc367a0
Unify approach from 0.17.x and central-develop
Sep 2, 2019
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
158 changes: 158 additions & 0 deletions kalite/coachreports/static/css/coachreports/exercise_mastery_view.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
.selection {
float: left;
padding: 0 10px 10px 0;
}

#displaygrid {
width: 100%;
padding-top: 5px;
padding-left: 2px;
}

#displaygrid > .users {
width: 11%;
margin-right: 1px;
float: left;
}

.userstatus {
overflow: auto;
width: 88%;
}

.users table {
width: 100%;
}

#displaygrid table {
table-layout: fixed;
}

th, td {
border: 1px solid black;
padding: 2px;
vertical-align:middle;
}

.users th {
text-align: left;
}

.subtitle {
font-size: 1.15em;
font-weight: bold;
}

.status {
height: 27px;
background-color: #EEE;
}

th.username {
height: 27px;
border: 1px solid black;
padding-left: 5px;
white-space: nowrap;
text-overflow: ellipsis;
}

th.headrow, th.headrow div {
width: 80px;
font-weight: bold;
background-color: white;
overflow: hidden;
text-overflow: ellipsis;
}

th.headrowuser {
font-weight: bold;
}

.complete {
background-color: #2F942F;
}

.partial {
background-color: #94BE48;
}

.struggle {
background-color: #CA4D4D;
}

#displaygrid td, #displaygrid th {
min-width: 60px;
max-width: 60px;
overflow: hidden;
}

#legend a {
height:12px;
margin:0px;
padding:0px;
}

.student-name, .attempts, .streak_progress, .points, .total_seconds_watched {
float:left;
display:none;
overflow:hidden;
white-space:nowrap;
width:100%;
margin:0px 5px 0px 0px;
padding:0px;
text-align:right;
vertical-align:middle;
}

.student-name {
float:none;
text-align:left;
display:block;
text-overflow: ellipsis;
}

#legend {
float:left;
vertical-align:middle;
margin:12px 25px 2px 10px;
}

.legend {
float:right;
width:160px;
height:20px;
text-align:center;
vertical-align:middle;
white-space:nowrap;
overflow:hidden;
border-style:solid;
border-width: 1px;
padding:2px;
margin-right: 10px;
font-weight: bold;
}

.legend div {
float:left;
width:35px;
height:21px;
}

#selection-bar {
overflow:hide;
}

#disp_options {
float:right;
}

.exercise-name {
height: 100px;
text-align: center;
vertical-align: none;
padding: 0px;
}

#exercise-mastery {
font-size: 10px
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a feature lost from 0.16.x - or it might be unwanted in 0.17?

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
$(function() {

$("#student").change(function() {
window.location.href = setGetParam(window.location.href, "user", $("#student option:selected").val());
});

$("#playlist").change(function() {
window.location.href = setGetParam(window.location.href, "playlist", $("#playlist option:selected").val());
});

$("#facility").change(function() {
window.location.href = setGetParamDict(window.location.href, {
"facility": $("#facility option:selected").val(),
"group": $("#" + $("#facility option:selected").val() + "_group_select").val(),
"playlist": ""
});
});

$(".group_select").change(function(event) {
window.location.href = setGetParam(window.location.href, "group", $(event.target).val());
});

// Selector to toggle visible elements is stored in each option value
cell_height = 27;
$("#disp_options").change(function() {
selector = $("#disp_options option:selected").val();

// adjust the cell height
cell_height += 50 * Math.pow(-1, 0 + $(selector).is(":visible"));

// adjust view in data cells
$(selector).each(function() {
$(this).toggle();
});
$(selector).each(function() {
$(this).height(20);
$(this).parent().height(cell_height);
});

// Adjust student name cell heights
$("th.username").each(function() {
$(this).height(cell_height);
});
});
$(window).resize(function() {
$('.headrowuser').height($('.headrow.data').height());
}).resize();
});

$(function(){
$("#tree").dynatree({
persist: true,
expand: false,
checkbox: true,
selectMode: 3,
cookieId: "exercises",
children: null,

onPostInit: function(isReloading, isError) {
if (window.location.href.indexOf("&playlist=") == -1) {
$("#tree").dynatree("getTree").visit(function(node){
node.select(false);
node.expand(false);
});
}
},
onSelect: function(select, dtnode) {
var selKeys = $.map(dtnode.tree.getSelectedNodes(), function(dtnode){
return dtnode.data.key;
});
window.location.href = setGetParam(window.location.href, "playlist", selKeys);
}
});
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a feature lost from 0.16.x - or it might be unwanted in 0.17?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two exercise_master_view changes are from: #3033

@aronasorman noted:

We can revisit the PRs merged into nalanda by looking at the nalanda-bugfixes milestone, and then porting whatever PRs are relevant to the develop branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CSS lives here:

https://github.com/learningequality/ka-lite/blob/master/kalite/coachreports/static/css/coachreports/tabular_view.less

I've searched the codebase for occurrences of "exercise_mastery_view", and as there are none, I will assume that the JS file is unused.

17 changes: 17 additions & 0 deletions kalite/control_panel/api_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,23 @@ def alter_list_data_to_serialize(self, request, to_be_serialized):
attempt_logs = AttemptLog.objects.filter(user=user, exercise_id=bundle.data["exercise_id"], context_type__in=["playlist", "exercise"])
bundle.data["timestamp_first"] = attempt_logs.count() and attempt_logs.aggregate(Min('timestamp'))['timestamp__min'] or None
bundle.data["timestamp_last"] = attempt_logs.count() and attempt_logs.aggregate(Max('timestamp'))['timestamp__max'] or None
bundle.data["unit"] = 0

# Anything done after Nov 15, 2014 is in the RCT which starts from Unit 101
if StoreTransactionLog.objects.filter(user=user, context_type="unit_points_reset", purchased_at__gte=datetime(2014, 11, 15, 0, 0, 0)).count() == 0:
bundle.data["unit"] = 101

elif bundle.data["timestamp_first"]:
for i in xrange(101,104):
if StoreTransactionLog.objects.filter(user=user, context_id=i, context_type="unit_points_reset", purchased_at__gte=bundle.data["timestamp_first"]).count() > 0:
bundle.data["unit"] = i
break

# For entries we are not sure about the unit, we keep them as 0, mostly chances are that the unit would be the current_unit.
# As we can't predict the current unit on the central server, its better to have the value as 0.
# We can't predict the current unit because in some database we have unit_point_reset gift card for unit 101 whereas the current unit is also 101.
# So we can't find current_unit by saying that the first unit that doesn't have the unit_point_reset gift card is current_unit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what all this is. Never heard about the "gift card" part nor the purchased_at__gte in the query further up? We don't have a model StoreTransactionLog anywhere, so I think all of this should go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StoreTransactionLog is a model from kalite.store which is an application we removed.

bundle.data["part1_answered"] = AttemptLog.objects.filter(user=user, exercise_id=bundle.data["exercise_id"], context_type__in=["playlist", "exercise"]).count()
bundle.data["part1_correct"] = AttemptLog.objects.filter(user=user, exercise_id=bundle.data["exercise_id"], correct=True, context_type__in=["playlist", "exercise"]).count()
bundle.data["part2_attempted"] = AttemptLog.objects.filter(user=user, exercise_id=bundle.data["exercise_id"], context_type__in=["exercise_fixedblock", "playlist_fixedblock"]).count()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ var ZoneSelectView = Backbone.View.extend({

template: require('./hbtemplates/zone-select.handlebars'),

initialize: function() {
initialize: function(options) {
// Create collections
this.zone_list = new Models.ZoneCollection();

Expand All @@ -117,7 +117,7 @@ var ZoneSelectView = Backbone.View.extend({
// Fetch collection by org_id
this.zone_list.fetch({
data: $.param({
"org_id": this.options.org_id,
"org_id": options.org_id,
"limit": 0
})
});
Expand Down
3 changes: 3 additions & 0 deletions kalite/distributed/management/commands/screenshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ def __init__(self, *args, **kwargs):
# After initializing the server (with setUp) and a browser, set the language
self.set_session_language(kwargs['language'])

# After initializing the server (with setUp) and a browser, set the language
self.set_session_language(kwargs['language'])

self.loginfo("==> Browser %s successfully setup with live_server_url %s." %
(self.browser.name, self.live_server_url,))
self.loginfo("==> Saving screenshots to %s ..." % (settings.SCREENSHOTS_OUTPUT_PATH,))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ require("browsernizr/test/canvas");
require("browsernizr/test/touchevents");
var Modernizr = require("browsernizr");

// Expose this as a global object for use in central server inline JS.
global.getCookie = require("utils/get_cookie");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be configurable and only switched on in the central server.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, this might actually be harmless to the rest of the KA Lite application, wouldn't you think so @rtibbles ?

global.$ = $;
global._ = _;
global.sessionModel = new SessionModel();
Expand Down
67 changes: 67 additions & 0 deletions kalite/packages/bundled/fle_utils/django_utils/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,73 @@ def call_command_async(cmd, *args, **kwargs):
return call_command_subprocess(cmd, *args, **kwargs)


def call_outside_command_with_output(command, *args, **kwargs):
"""
Runs call_command for a KA Lite installation at the given location,
and returns the output.
"""

if settings.IS_SOURCE:
assert "kalite_dir" in kwargs, "don't forget to specify the kalite_dir"
kalite_dir = kwargs.pop('kalite_dir')
else:
kalite_dir = None

# some custom variables that have to be put inside kwargs
# or else will mess up the way the command is called
output_to_stdout = kwargs.pop('output_to_stdout', False)
output_to_stderr = kwargs.pop('output_to_stderr', False)
wait = kwargs.pop('wait', True)

# build the command
if kalite_dir:
kalite_bin = os.path.join(kalite_dir, "bin", "kalite")
else:
kalite_bin = 'kalite'

cmd = (kalite_bin, "manage", command) if os.name != "nt" else (sys.executable, kalite_bin, "manage", command)
for arg in args:
cmd += (arg,)

kwargs_keys = kwargs.keys()

# Ensure --settings occurs first, as otherwise docopt parsing barfs
kwargs_keys = sorted(kwargs_keys, cmp=lambda x,y: -1 if x=="settings" else 0)

for key in kwargs_keys:
val = kwargs[key]
key = key.replace(u"_",u"-")
prefix = u"--" if command != "runcherrypyserver" else u"" # hack, but ... whatever!
if isinstance(val, bool):
cmd += (u"%s%s" % (prefix, key),)
else:
# TODO(jamalex): remove this replacement, after #4066 is fixed:
# https://github.com/learningequality/ka-lite/issues/4066
cleaned_val = unicode(val).replace(" ", "")
cmd += (u"%s%s=%s" % (prefix, key, cleaned_val),)

# we also need to change the environment to point to the the local
# kalite settings. This is especially important for when the
# central server calls this function, as if we don't change this,
# kalitectl.py wil look for centralserver.settings instead of
# kalite.settings.
new_env = os.environ.copy()
new_env["DJANGO_SETTINGS_MODULE"] = kwargs.get("settings") or "kalite.settings"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should ideally be configurable and only switched on in the central server. The whole function is only used in a test, though, centralserver/central/tests/utils/distributed_server_factory.py.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all this code is used from the central server's test suite, I'm moving it there.


p = subprocess.Popen(
cmd,
shell=False,
# cwd=os.path.split(cmd[0])[0],
stdout=None if output_to_stdout else subprocess.PIPE,
stderr=None if output_to_stderr else subprocess.PIPE,
env=new_env,
)
out = p.communicate() if wait else (None, None)

# tuple output of stdout, stderr, exit code and process object
return out + (1 if out[1] else 0, p)


class LocaleAwareCommand(BaseCommand):
option_list = BaseCommand.option_list + (
make_option('--locale',
Expand Down
6 changes: 3 additions & 3 deletions kalite/packages/bundled/securesync/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

class BaseClient(object):

def __init__(self, host="%s://%s/" % (settings.SECURESYNC_PROTOCOL, settings.CENTRAL_SERVER_HOST), require_trusted=True, verbose=True):
self.parsed_url = urllib2.urlparse.urlparse(host)
self.url = "%s://%s" % (self.parsed_url.scheme, self.parsed_url.netloc)
def __init__(self, host=None, require_trusted=True, verbose=True):
self.url = host or settings.CENTRAL_SERVER_URL
self.parsed_url = urllib2.urlparse.urlparse(self.url)
self.require_trusted = require_trusted
self.verbose = verbose

Expand Down
Loading