-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathcheck.py
56 lines (42 loc) · 1.21 KB
/
check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Script de comprobación de entrega de ejercicio
Para ejecutarlo, desde la shell:
$ python check.py login_github
"""
import os
import random
import sys
ejercicio = 'X-Serv-13.5-Python'
if len(sys.argv) != 2:
print
sys.exit("Usage: $ python check.py login_github")
repo_git = "http://github.com/" + sys.argv[1] + "/" + ejercicio
files = ['README.md',
'.gitignore',
'passwd.py',
'check.py',
'.git']
aleatorio = str(int(random.random() * 1000000))
error = 0
print
print "Clonando el repositorio " + repo_git + "\n"
os.system('git clone ' + repo_git + ' /tmp/' + aleatorio + ' > /dev/null 2>&1')
try:
student_file_list = os.listdir('/tmp/' + aleatorio)
except OSError:
error = 1
print "Error: No se ha podido acceder al repositorio " + repo_git + "."
print
sys.exit()
if len(student_file_list) != len(files):
error = 1
print "Error: número de ficheros en el repositorio incorrecto"
for filename in files:
if filename not in student_file_list:
error = 1
print "\tError: " + filename + " no encontrado en el repositorio."
if not error:
print "Parece que la entrega se ha realizado bien."
print