root 3 years ago
parent
commit
7847801474
1 changed files with 139 additions and 205 deletions
  1. 139
    205
      app.py

+ 139
- 205
app.py View File

@@ -134,25 +134,28 @@ def executeSudoCmds(cmds):
134 134
     for cmd in cmds:
135 135
         if type(cmd).__name__ == 'list' :
136 136
             for subCmd in cmd:
137
-                if subCmd.find('cd ') == -1:
138
-                    end.append(sudoCmd(subCmd))
139
-                else:
137
+                if 5 > subCmd.find('cd') and -1 != subCmd.find('cd'):
140 138
                     end.append(subCmd)
139
+                else:
140
+                    end.append(sudoCmd(subCmd))
141 141
 
142 142
         else:
143
-            if cmd.find('cd ') == -1:
144
-                end.append(sudoCmd(cmd))
145
-            else:
143
+            if 5 > cmd.find('cd') and -1 != cmd.find('cd'):
146 144
                 end.append(cmd)
147
-
148
-    cmd = (' ' + cmdsSeparator +' ').join(end)
149
-    executeCmd(cmd)
145
+            else:
146
+                end.append(sudoCmd(cmd))
147
+                
148
+    executeCmds(end)
150 149
     #executeSudoCmd('; '.join(end))
151 150
 
152 151
 def executeCmd(cmd):
153 152
     dump(cmd)
154 153
     os.system(cmd)
155 154
 
155
+def executeCmds(cmds):
156
+    cmd = (' ' + cmdsSeparator +' ').join(cmds)
157
+    executeCmd(cmd)
158
+
156 159
 def copyCmd(pathFrom,pathTo,userTo):
157 160
     return [
158 161
         cpPath + ' -r \'' + pathFrom + '\' \'' + pathTo + '\'',
@@ -642,8 +645,7 @@ et met en place le contenu du notebook si précisé en paramètre(@param content
642 645
 @param content
643 646
 @param force force le remplacement du notebook
644 647
 """
645
-def initUserSpace(jupyterUsername,folder,notebookname,fromurl = None,content = ''):
646
-    path = getNotebookPath(jupyterUsername,folder,notebookname)
648
+def initUserSpace(jupyterUsername,folder = None,notebookname = None,fromurl = None,content = ''):
647 649
     dump('initUserSpace')
648 650
    
649 651
     if fromurl != None:
@@ -660,28 +662,30 @@ def initUserSpace(jupyterUsername,folder,notebookname,fromurl = None,content = '
660 662
 
661 663
         # dossier ./source
662 664
         # débloquage de l'origine
663
-        mvCmds = []
664
-        mvCmds.append(unlockSourceCmd(fromJupyterUuid))
665
-        mvCmds.append(unlockSourceCmd(jupyterUsername))
666
-        
667
-        # déplace le dossier
668
-        mvCmds.append(mvCmd(
669
-            buildPath(['home',fromJupyterUuid,'source',fromFolder]),
670
-            buildPath(['home',jupyterUsername,'source',folder])
671
-        ))
672
-
673
-        mvCmds.append(lockSourceCmd(fromJupyterUuid))
674
-        mvCmds.append(lockSourceCmd(jupyterUsername))
675
-
676
-        executeSudoCmds(mvCmds)
677
-
678
-        # déplace le fichier du notebook s'il existe
679
-        moveCmd = mvCmd(
680
-            buildPath(['home',jupyterUsername,'source',folder,fromNotebookName]),
681
-            buildPath(['home',jupyterUsername,'source',folder,notebookname]),
682
-            jupyterUsername
683
-        )
684
-        executeSudoCmds(moveCmd)
665
+        if folder:
666
+            mvCmds = []
667
+            mvCmds.append(unlockSourceCmd(fromJupyterUuid))
668
+            mvCmds.append(unlockSourceCmd(jupyterUsername))
669
+            
670
+            # déplace le dossier
671
+            mvCmds.append(mvCmd(
672
+                buildPath(['home',fromJupyterUuid,'source',fromFolder]),
673
+                buildPath(['home',jupyterUsername,'source',folder])
674
+            ))
675
+
676
+            mvCmds.append(lockSourceCmd(fromJupyterUuid))
677
+            mvCmds.append(lockSourceCmd(jupyterUsername))
678
+
679
+            executeSudoCmds(mvCmds)
680
+
681
+            # déplace le fichier du notebook s'il existe
682
+            if notebookname:
683
+                moveCmd = mvCmd(
684
+                    buildPath(['home',jupyterUsername,'source',folder,fromNotebookName]),
685
+                    buildPath(['home',jupyterUsername,'source',folder,notebookname]),
686
+                    jupyterUsername
687
+                )
688
+                executeSudoCmds(moveCmd)
685 689
 
686 690
     else:
687 691
          # -- config notebook jupyter
@@ -691,19 +695,20 @@ def initUserSpace(jupyterUsername,folder,notebookname,fromurl = None,content = '
691 695
         mkdirCmds = mkdirCmd(buildPath(['home',jupyterUsername,'source']),jupyterUsername)
692 696
         executeSudoCmds(mkdirCmds)
693 697
         
694
-        # débloquage de source
695
-        myCmds = []
696
-        myCmds.append(unlockSourceCmd(jupyterUsername))
698
+        if folder:
699
+            # débloquage de source
700
+            myCmds = []
701
+            myCmds.append(unlockSourceCmd(jupyterUsername))
697 702
 
698
-        # dossier ./[folder]
699
-        myCmds.append(mkdirCmd(buildPath(['home',jupyterUsername,'source',folder]),jupyterUsername))
703
+            # dossier ./[folder]
704
+            myCmds.append(mkdirCmd(buildPath(['home',jupyterUsername,'source',folder]),jupyterUsername))
700 705
 
701
-        # bloquage du source
702
-        myCmds.append(lockSourceCmd(jupyterUsername))
706
+            # bloquage du source
707
+            myCmds.append(lockSourceCmd(jupyterUsername))
703 708
 
704
-        executeSudoCmds(myCmds)
709
+            executeSudoCmds(myCmds)
705 710
 
706
-    if content != '': 
711
+    if content != '' and folder and notebookname:
707 712
         write(jupyterUsername,buildPath(['home',jupyterUsername,'source',folder,notebookname]),content)
708 713
 
709 714
     # demande le token utilisateur
@@ -760,7 +765,6 @@ def cleanQuotes(string):
760 765
 
761 766
 def nbGraderInstallCmd(user,options):
762 767
     result = [
763
-        goToUser(user),
764 768
         jupyterPath + ' ' + nbextensionPath + ' install --user --py nbgrader',
765 769
         jupyterPath + ' ' + nbextensionPath + ' disable --user --py nbgrader'
766 770
     ]
@@ -768,18 +772,24 @@ def nbGraderInstallCmd(user,options):
768 772
     for option in options:
769 773
         result.append(jupyterPath + ' ' + nbextensionPath + ' enable --user ' + option)
770 774
     
771
-    return sudoCmd(runAsUser(user,(' ' + cmdsSeparator + ' ').join(result)))
775
+    return formatNbgraderSudoCmd(user,result)
776
+
777
+def formatNbgraderSudoCmd(user,commands):
778
+    return sudoCmd(formatNbgraderCmd(user,commands))
772 779
 
773
-def writeConfigurations(jupyterUsername,useSource=True):
780
+def formatNbgraderCmd(user,commands):
781
+    return runAsUser(user,(' ' + cmdsSeparator + ' ').join([goToUser(user)] + commands))
782
+
783
+def writeConfigurations(jupyterUsername):
774 784
     # config du notebook jupyter => changement de la racine d'exploration
775 785
     mkdirCmds = mkdirCmd(buildPath(['home',jupyterUsername,'.jupyter']),jupyterUsername,770)
776 786
     executeSudoCmds(mkdirCmds)
777 787
 
778 788
     configContents = []
779
-    if useSource:
780
-        configContents.append('c.FileContentsManager.root_dir=\'' + buildPath(['home',jupyterUsername,'source']) + '\'')
781
-        configContents.append('c.NotebookApp.notebook_dir=\'' + buildPath(['home',jupyterUsername,'source']) + '\'')
782 789
     
790
+    configContents.append('c.FileContentsManager.root_dir=\'' + buildPath(['home',jupyterUsername,'source']) + '\'')
791
+    configContents.append('c.NotebookApp.notebook_dir=\'' + buildPath(['home',jupyterUsername,'source']) + '\'')
792
+
783 793
     configContents.append('c.MappingKernelManager.cull_idle_timeout = ' + timeout)
784 794
     configContents.append('c.MappingKernelManager.shutdown_no_activity_timeout = ' + timeout)
785 795
     
@@ -790,6 +800,38 @@ def writeConfigurations(jupyterUsername,useSource=True):
790 800
     #myCmd += ' && chattr +i ' +  buildPath(['home',jupyterUsername,'.jupyter','jupyter_notebook_config.py'])
791 801
     #os.system(myCmd)
792 802
 
803
+def processCreateUser(token,username,folder,notebookname,fromPath,content,callback):
804
+    # cree l'utilisateur s'il n'existe pas
805
+    # + ouvre son serveur
806
+    result = openServer(token,username)
807
+
808
+    jupyterUsername = getJupyterName(username)
809
+
810
+    # cas d'une creation de compte utilisateur, il faut le configurer
811
+    if 'token' in result['resultUser'] and ((not 'status' in result['result']) or (result['result']['status'] != '400')):
812
+        # ajout l'utilisateur courant au groupe du nouvel utiliosateur
813
+        # + change les droits du groupe sur le dossier de l'utilisateur
814
+        cmd = changeFolderRightForGroup(jupyterUsername)
815
+        executeSudoCmd(cmd)
816
+
817
+        callback(jupyterUsername)
818
+
819
+        # configuration des extensions de l'utilisateur
820
+        # config formateur de nbgrader
821
+        myCmds = nbGraderInstallCmd(jupyterUsername,['create_assignment/main','validate_assignment/main'])
822
+        executeCmd(myCmds)
823
+
824
+        writeConfigurations(jupyterUsername)
825
+
826
+        # stop server instance
827
+        # 400 = deja stoppe
828
+        doStopServer(token,username,[202,204,400])
829
+
830
+    # creation du notebook
831
+    initUserSpace(jupyterUsername,folder,notebookname,fromPath,content)
832
+
833
+    return result
834
+
793 835
 """
794 836
 url: [host]/trainer/<username>/<folder>/<notebookName>
795 837
 """
@@ -819,44 +861,11 @@ def createTrainerServer(username,folder,notebookname):
819 861
     if 'notebookContent' in request:
820 862
         content = request['notebookContent']
821 863
 """
822
-
823
-    # cree l'utilisateur s'il n'existe pas
824
-    # + ouvre son serveur
825
-    result = openServer(token,username)
826
-
827
-# cas d'une creation de compte utilisateur, il faut le configurer
828
-    if 'token' in result['resultUser'] and ((not 'status' in result['result']) or (result['result']['status'] != '400')):
829
-        # ajout l'utilisateur courant au groupe du nouvel utiliosateur
830
-        # + change les droits du groupe sur le dossier de l'utilisateur
831
-        jupyterUsername = getJupyterName(username)
832
-        cmd = changeFolderRightForGroup(jupyterUsername)
833
-        executeSudoCmd(cmd)
834
-
835
-        cmd = addCurrentUserToJupyterUserGroup(jupyterUsername)
864
+    def callback(name):
865
+        cmd = addCurrentUserToJupyterUserGroup(name)
836 866
         executeSudoCmd(cmd)
837 867
 
838
-        # configuration des extensions de l'utilisateur
839
-        # config formateur de nbgrader
840
-        myCmds = nbGraderInstallCmd(jupyterUsername,['create_assignment/main','validate_assignment/main'])
841
-        executeCmd(myCmds)
842
-
843
-        #myCmd += ' && ' + sudoPath + ' -u ' + currentUserName + ' ' + chmodPath + ' 770 ' + buildPath(['home',jupyterUsername,'.jupyter'])
844
-        writeConfigurations(jupyterUsername)
845
-
846
-        #dump(os.popen(myCmd).read())
847
-
848
-        # ajoute la configuration de jupyter
849
-        #configContent = "c.FileContentsManager.root_dir='" + buildPath(['home',jupyterUsername,'source']) + "'\n"
850
-        #configContent += "c.NotebookApp.notebook_dir ='c.FileContentsManager.root_dir='" + buildPath(['home',jupyterUsername,'source']) + "'"
851
-        #configPath =  '/home/' + jupyterUsername + '/.jupyter/jupyter_notebook_config.py'
852
-        #write('root',configPath,configContent)
853
-
854
-        # stop server instance
855
-        # 400 = deja stoppe
856
-        doStopServer(token,username,[202,204,400])
857
-
858
-    # creation du notebook
859
-    initUserSpace(jupyterUsername,folder,notebookname,fromPath,content)
868
+    result = processCreateUser(token,username,folder,notebookname,fromPath,content,callback)
860 869
 
861 870
     # retourne l'url menant au notebook
862 871
     userToken = None
@@ -887,41 +896,15 @@ def createStudentServer(trainername,username,folder,notebookname):
887 896
     # recupere le contenu
888 897
     content = getRequestData('content')
889 898
 
890
-    # cree l'utilisateur s'il n'existe pas
891
-    # + ouvre son serveur
892
-    result = openServer(token,username)
893
-
894 899
     jupyterUsername = getJupyterName(username)
895 900
     trainerJupyterUsername = getJupyterName(trainername)
896 901
 
897
-    #
898
-    # cas d'une creation de compte utilisateur, il faut le configurer en tant que formateur
899
-    if 'token' in result['resultUser'] and ((not 'status' in result['result']) or (result['result']['status'] != '400')):
900
-        # ajout l'utilisateur courant au groupe du nouvel utiliosateur
901
-        # + change les droits du groupe sur le dossier de l'utilisateur
902
-        jupyterUsername = getJupyterName(username)
903
-        cmd = changeFolderRightForGroup(jupyterUsername)
904
-        executeSudoCmd(cmd)
905
-
906
-        cmd = addCurrentUserToJupyterUserGroup(jupyterUsername)
907
-        executeSudoCmd(cmd)
908
-
909
-        myCmd = nbGraderInstallCmd(jupyterUsername,[])
902
+    def callback(name):
903
+        myCmd = nbGraderInstallCmd(name,[])
910 904
         executeCmd(myCmd)
911 905
 
912
-        # config du notebook jupyter => changement de la racine d'exploration
913
-        mkdirCmds = mkdirCmd(buildPath(['home',jupyterUsername,'.jupyter']),jupyterUsername,770)
914
-        executeSudoCmds(mkdirCmds)
915
-
916
-        writeConfigurations(jupyterUsername)
917
-
918
-        # stop server instance
919
-        # 400 = deja stoppe
920
-        doStopServer(token,username,[202,204,400])
906
+    result = processCreateUser(token,username,folder,notebookname,None,'',callback)
921 907
     
922
-    # creation du notebook, le mode force permet de reecrire le notebook
923
-    initUserSpace(jupyterUsername,folder,notebookname,None)
924
-
925 908
     # copie du dossier formateur
926 909
     copyCmds = []
927 910
     copyCmds.append(unlockSourceCmd(jupyterUsername))
@@ -948,7 +931,6 @@ def createStudentServer(trainername,username,folder,notebookname):
948 931
     response = {'result' : True,'tokenId' : tokenId,'token' : userToken, 'url' : getNotebookUrl(username,folder,notebookname),'notebookName': notebookname }
949 932
     return json.dumps(response),200
950 933
 
951
-
952 934
 """
953 935
 url: [host]/assesment/student/<trainername>/<username>/<fodler>/<notebookName>
954 936
 """
@@ -966,94 +948,43 @@ def createAssesmentStudentServer(trainername,username,folder,notebookname):
966 948
     jupyterUsername = getJupyterName(username)
967 949
     jupyterTrainername = getJupyterName(trainername)
968 950
 
969
-    # assign le cours
970
-    addAssigmentCmd = goToUser(jupyterTrainername)
971
-    addAssigmentCmd += ' && ' + nbgraderPath + ' db assignment add \'' + folder + '\''
972
-    addAssigmentCmd = runAsUser(jupyterTrainername,addAssigmentCmd)
973
-    dump(addAssigmentCmd)
974
-    os.system(addAssigmentCmd)
975
-
976
-    assignCmd = goToUser(jupyterTrainername)
977
-    assignCmd += ' && ' + nbgraderPath + ' assign \'' + folder + '\''
978
-    assignCmd = runAsUser(jupyterTrainername,assignCmd)
979
-    dump(assignCmd)
980
-    os.system(assignCmd)
951
+    # ajoute le cours à la base de donnée
952
+    executeCmd(formatNbgraderSudoCmd(jupyterTrainername,[nbgraderPath + ' db assignment add \'' + folder + '\'']))
953
+    # créé la version du cours afin qu'elle soit releasé pour les apprenant
954
+    executeCmds([
955
+        goToUser(jupyterTrainername),
956
+        sudoCmd(nbgraderPath + ' assign \'' + folder + '\''),
957
+    ])
981 958
 
982 959
     # release le cours formateur
983 960
     # trainer name
984 961
     # course name
985
-    releaseCmd = goToUser(jupyterTrainername)
986
-    releaseCmd += ' && ' + nbgraderPath + ' release \'' + folder + '\' --course="' + folder + '" --force'
987
-    releaseCmd = runAsUser(jupyterTrainername,releaseCmd)
988
-    dump(releaseCmd)
989
-    os.system(releaseCmd)
962
+    executeCmds([
963
+        goToUser(jupyterTrainername),
964
+        sudoCmd(nbgraderPath + ' release \'' + folder + '\' --course="' + folder + '" --force'),
965
+    ])
990 966
 
991 967
     # cree l'utilisateur s'il n'existe pas
992 968
     # + ouvre son serveur
993 969
     result = openServer(token,username),200
994
-    
995
-# cas d'une creation de compte utilisateur, il faut le configurer
996
-    if 'token' in result['resultUser'] and ((not 'status' in result['result']) or (result['result']['status'] != '400')):
997
-        
998
-        # assignation du groupe à l'utilisateur executant le script
999
-
1000
-        
1001
-        # configuration des extensions de l'utilisateur
1002
-        # config formateur de nbgrader
1003
-        myCmd = goToUser(jupyterUsername)
1004
-
1005
-        myCmd += ' && ' + nbextensionPath + ' install --user --py nbgrader'
1006
-        myCmd += ' && ' + nbextensionPath + ' disable --user --py nbgrader'
1007
-        myCmd = runAsUser(jupyterUsername,myCmd)
1008
-        dump(myCmd)
1009
-        os.system(myCmd)
1010
-
1011
-        # timeout de deconnexion
1012
-        myCmd = 'echo "c.MappingKernelManager.cull_idle_timeout = ' + timeout + '" >> ' + buildPath(['home',jupyterUsername,'.jupyter','jupyter_notebook_config.py'])
1013
-        myCmd += ' && echo "c.MappingKernelManager.shutdown_no_activity_timeout = ' + timeout + '" >> ' + buildPath(['home',jupyterUsername,'.jupyter','jupyter_notebook_config.py'])
1014
-        myCmd = runAsUser(jupyterUsername,myCmd)
1015
-        dump(myCmd)
1016
-        os.system(myCmd)
1017
-        
1018 970
 
1019
-        # stop server instance
1020
-        # 400 = deja stoppe
1021
-        doStopServer(token,username,[202,204,400])
971
+    def callback(name):
972
+        myCmd = nbGraderInstallCmd(name,[])
973
+        executeCmd(myCmd)
1022 974
 
975
+    result = processCreateUser(token,username,None,None,None,'',callback)
976
+ 
1023 977
      # ajoute l'apprenant dans la base local nbgrader du formateur
1024
-    addStudentCmd = goToUser(jupyterTrainername)
1025
-    addStudentCmd += ' && ' + nbgraderPath + ' db student add ' + jupyterUsername
1026
-
1027
-    addStudentCmd = runAsUser(jupyterTrainername,addStudentCmd)
1028
-    dump(addStudentCmd)
1029
-
1030
-    os.system(addStudentCmd)
1031
-
1032
-    # creation du notebook, le mode force permet de reecrire le notebook
1033
-    # creation des dossiers
1034
-    # débloquage du source
1035
-    myCmd = chattrPath + ' -i \'' + buildPath(['home',jupyterUsername,'source']) + '\''
1036
-    # dossier ./source
1037
-    myCmd += ' && ' + sudoPath + ' -u ' + jupyterUsername + ' ' + mkdirPath + ' -p \''+ buildPath(['home',jupyterUsername,'source']) +'\''
1038
-    # dossier ./cours
1039
-    myCmd += ' && ' + sudoPath + ' -u ' + jupyterUsername + ' ' + mkdirPath + ' \''+ buildPath(['home',jupyterUsername,'source',folder]) + '\''
1040
-    # bloquage du source
1041
-    myCmd += ' && ' + chattrPath + ' +i \''+ buildPath(['home',jupyterUsername,'source']) +'\''
1042
-
1043
-    dump(myCmd)    
1044
-    os.system(myCmd)
978
+    executeCmd(formatNbgraderSudoCmd(jupyterTrainername,[nbgraderPath + ' db student add ' + jupyterUsername]))
1045 979
 
1046 980
      # recupere la release chez l'apprenant
1047 981
     #sudo -u jupyter-{name} nbgrader fetch cours --course cours
1048
-    getCmd = goToUser(jupyterUsername)
1049
-    getCmd += ' && ' + chattrPath + ' -i ' + buildPath(['home',jupyterUsername,'source'])
1050
-    getCmd += ' && ' + runAsUser(jupyterUsername,'cd ./source && ' + nbgraderPath + ' fetch "' + folder + '" --course "' + folder + '"')
1051
-    getCmd += ' && ' + chattrPath + ' +i ' + buildPath(['home',jupyterUsername,'source'])
1052
-    
1053
-    getCmd = sudo(getCmd)
1054
-    dump(getCmd)
1055
-
1056
-    os.system(getCmd)
982
+    getCourseCmd = []
983
+    getCourseCmd.append(unlockSourceCmd(jupyterUsername))
984
+    getCourseCmd.append(goToUser(jupyterUsername))
985
+    getCourseCmd.append(nbgraderPath + ' fetch "' + folder + '" --course "' + folder + '"')
986
+    getCourseCmd.append(lockSourceCmd(jupyterUsername))
987
+    executeSudoCmds(getCourseCmd)
1057 988
 
1058 989
     # retourne l'url menant au notebook
1059 990
     userToken = None
@@ -1063,7 +994,7 @@ def createAssesmentStudentServer(trainername,username,folder,notebookname):
1063 994
     if 'tokenId' in result['resultUser']:
1064 995
         tokenId = result['resultUser']['tokenId']
1065 996
 
1066
-    response = {'result' : True,'tokenId' : tokenId,'token' : userToken, 'url' : getNotebookUrl(jupyterUsername,folder,notebookname),'notebookName':notebookName }
997
+    response = {'result' : True,'tokenId' : tokenId,'token' : userToken, 'url' : getNotebookUrl(jupyterUsername,folder,notebookname),'notebookName':notebookname }
1067 998
     return json.dumps(response),200
1068 999
 
1069 1000
 
@@ -1089,27 +1020,30 @@ def sendStudentNotebook(trainername,username,folder):
1089 1020
     jupyterUsername = getJupyterName(username)
1090 1021
     trainerJupyterUsername = getJupyterName(trainername)
1091 1022
     folder = cleanFolderName(folder)
1092
-    sendCommand = runAsUser(jupyterUsername,'cd ./source && ' + nbgraderPath + ' submit "' + folder + '" --course "' + folder + '" --student=' + jupyterUsername)
1093
-    dump(sendCommand)
1094
-    os.system(sendCommand)
1095 1023
 
1024
+    # envoi du code de l'apprenant
1025
+    executeCmds([
1026
+        goToUser(jupyterUsername),
1027
+        sudoCmd(nbgraderPath + ' submit "' + folder + '" --course "' + folder + '" --student=' + jupyterUsername)
1028
+    ])
1029
+    
1096 1030
     # recuperation cote formateur + analyse pour evaluation automatique
1097
-    generateScoreCommand = goToUser(trainerJupyterUsername)
1098
-    generateScoreCommand += ' && ' + nbgraderPath + ' collect "' + folder + '" --course="' + folder + '" --update'
1099
-    dump(sendCommand)
1100
-    os.system(generateScoreCommand)
1031
+    executeCmds([
1032
+        goToUser(trainerJupyterUsername),
1033
+        sudoCmd(nbgraderPath + ' collect "' + folder + '" --course="' + folder + '" --update')
1034
+    ])
1101 1035
 
1102 1036
     # evaluation automatique
1103
-    autogradeCommand = goToUser(trainerJupyterUsername)
1104
-    autogradeCommand += ' && ' + nbgraderPath + ' autograde "' + folder + '" --student="' + jupyterUsername + '"'
1105
-    os.system(autogradeCommand)
1037
+    executeCmds([
1038
+        goToUser(trainerJupyterUsername),
1039
+        sudoCmd(nbgraderPath + ' autograde "' + folder + '" --student="' + jupyterUsername + '"')
1040
+    ])
1106 1041
 
1107 1042
     # extraction du score
1108
-    getScoresCommand = goToUser(trainerJupyterUsername)
1109
-    getScoresCommand += ' && ' + nbgraderPath + ' export'
1110
-    dump(getScoresCommand)
1111
-    os.system(getScoresCommand)
1112
-
1043
+    executeCmds([
1044
+        goToUser(trainerJupyterUsername),
1045
+        sudoCmd(nbgraderPath + ' export')
1046
+    ])
1113 1047
 
1114 1048
     score = None
1115 1049
     maxScore = None
@@ -1127,7 +1061,7 @@ def sendStudentNotebook(trainername,username,folder):
1127 1061
 """
1128 1062
 url: [host]/contents/<uuid>/<folder>/<notebook>
1129 1063
 """
1130
-# route permettant d'envoyer le code de l'apprenant de de lancer son evaluation
1064
+
1131 1065
 @app.route(buildRoutePath(['contents','<uuid>','<folder>','<notebook>']),methods=['GET'])
1132 1066
 def getNotebookContent(uuid,folder,notebook):
1133 1067
     folder = cleanFolderName(folder)

Loading…
Cancel
Save