def test_anon_user_loads_index(self):
        graph = get_facebook_graph(access_token='new_user')
        action, user = connect_user(self.request, facebook_graph=graph)

        self.request.user = AnonymousUser()
        response = views.index(self.request)
        print response.cookies
Beispiel #2
0
def clonedrives(request):
    if request.user.is_authenticated():
	username=request.user.username
	hddlist = []
	goodmark = 0
	remotepass = "******"
	clonestring = "sudo dcfldd if=/dev/"
	tobecloned = ""
	for i in range(98, 122):
            hddletter = chr(i)
            hdd = subprocess.Popen(remotepass + "ls /sys/block | grep sd%s" %hddletter, stdout=subprocess.PIPE, shell=True)
            hdd = hdd.stdout.read().strip()
            if hdd != '':
                hddlocation = subprocess.Popen(remotepass + "file /sys/block/%s" %hdd, stdout=subprocess.PIPE, shell=True)
                hddlocation = hddlocation.stdout.read()[-20:-18].strip()
                hddlocation = locator(hddlocation)
                if hddlocation == 1:
                    clonestring = clonestring + hdd
                    goodmark = 1
                else:
                    tobecloned = tobecloned + " of=/dev/" + hdd
        if goodmark == 0:
            return HttpResponse('no drive is loaded in slot one.  please load a drive in slot one to be cloned')
        elif tobecloned == "/":
            return HttpResponse("there are no drives to be cloned. this ain't gonna work")
        else:
            clonestring = clonestring + tobecloned + " &"
            subprocess.call([clonestring], shell=True)
            return render(request, 'drivetool/clone.html',
			 {"username":username,
			 })
    else:
	return index(request)
    def test_anon_user_loads_index(self):
        graph = get_facebook_graph(access_token='new_user')
        action, user = connect_user(self.request, facebook_graph=graph)

        self.request.user = AnonymousUser()
        response = views.index(self.request)
        print response.cookies
Beispiel #4
0
def cloneverify(request):
    if request.user.is_authenticated():
        username = request.user.username
        return render(request, 'drivetool/cloneverify.html',
                     {"username":username,
                     })
    else:
	return index(request)
Beispiel #5
0
def configure(request):
    if request.user.is_authenticated():
	username = request.user.username
	return render(request, 'drivetool/configure.html',
		     {"username":username,
		     })
    else:
	return index(request)
Beispiel #6
0
def newspostform(request):
    if request.user.is_authenticated():
	username = request.user.username
	return render(request, 'newsfeed/post.html',
		     {"username":username,
		     })
    else:
	return index(request)
Beispiel #7
0
def postdeleted(request):
    if request.user.is_authenticated():
	username = request.user.username
	newsid = request.POST.get("newsid")
	newstodelete = newsitem.objects.filter(id=request.POST.get("newsid"))
	newstodelete.delete()
	return homepage(request)
    else:
	return index(request)
Beispiel #8
0
def delete(request):
    if request.user.is_authenticated():
	username = request.user.username
	newsitems = newsitem.objects.filter(user_name = username).order_by('-pub_date')
	return render(request, 'newsfeed/delete.html',
		{"username":username,
		 "newsitems":newsitems,
		})
    else:
	return index(request)
Beispiel #9
0
def main(request):
    if request.user.is_authenticated():
	username = request.user.username
	test = request.user
	return render(request, 'edituser/edituser.html',
			{'username':username,
			 "userdetails":test,
			})
    else:
	return index(request)
Beispiel #10
0
def checkstatus(request):
    if request.user.is_authenticated():
        username = request.user.username
	remotepass = "******"

        return render(request, 'drivetool/checkstatus.html',
                     {"username":username,
                     })
    else:
	return index(request)
Beispiel #11
0
def savechanges(request):
    if request.user.is_authenticated():
	user = request.user
	user.first_name = request.POST.get('firstname')
	user.last_name = request.POST.get('lastname')
	user.email = request.POST.get('email')
	user.save()
	username = request.user.username
	return homepage(request)
    else:
	return index(request)
    def test_login_with_Facebook2(self):
        graph = get_facebook_graph(access_token='short_username')
        action, user = connect_user(self.request, facebook_graph=graph)
        user.save()
        self.request.user = AnonymousUser()
        graph = get_facebook_graph(access_token='same_username')
        action, new_user = connect_user(self.request, facebook_graph=graph)

        self.request.GET._mutable = True
        self.request.GET['testing'] = 'True'
        response = views.index(self.request)
        print response.content
    def test_login_with_Facebook2(self):
        graph = get_facebook_graph(access_token='short_username')
        action, user = connect_user(self.request, facebook_graph=graph)
        user.save()
        self.request.user = AnonymousUser()
        graph = get_facebook_graph(access_token='same_username')
        action, new_user = connect_user(self.request, facebook_graph=graph)


        self.request.GET._mutable = True
        self.request.GET['testing'] = 'True'
        response = views.index(self.request)
        print response.content
Beispiel #14
0
def message(request):
    if request.user.is_authenticated():
	username = request.user.username
	users = User.objects.filter().distinct()
	temp = "all users: "
	for i in users:
	    temp = temp + i.username + ", "
	return render(request, 'newsfeed/message.html',
		{"username":username,
		 "users":users,
		 "temp": temp,
		})
    else:
	return index(request)
Beispiel #15
0
def check(request):
    if request.user.is_authenticated():
	username = request.user.username
	try:
	    check = subprocess.check_output("ssh [email protected] ps aux | grep [d]cfldd", shell=True)
	    return render(request, 'drivetool/inuse.html',
		     {"username":username,
		     })
	except:
	    return render(request, 'drivetool/popup.html',
		     {"username":username,
		     })
    else:
	return index(request)
Beispiel #16
0
def passwordchanged(request):
    if request.user.is_authenticated():
	username = request.user.username
	passwordtest = request.POST.get('currentpassword')
	newpassword = request.POST.get('newpassword1')
	newpassword2 = request.POST.get('newpassword2')
	newuser = User.objects.get(username=username)
	user = authenticate(username = username, password = passwordtest)
	if user is not None:
	    if user.is_active:
		if newpassword == newpassword2:
		    newuser.set_password(newpassword)
		    newuser.save()
		    logout(request)
		    return index(request)
		else:
		    blob = newpassword + " : " + newpassword2
		    return HttpResponse("your new passwords don't match eachother, oh no")
	    else:
		return HttpResponse("that's odd.  it appears you aren't an active user")
	else:
	    return HttpResponse("I could not verify your password, please try again")
    else:
	return index(request)
Beispiel #17
0
def posttonews(request):
    if request.user.is_authenticated():
	username = request.user.username
	title = request.POST.get('title')
	newstext = request.POST.get('newstext')
	now = datetime.datetime.now()
	receiver = request.POST.get('receiver')
	if title == '':
	    return HttpResponse('please enter in a title for your fancy little news post')
	elif newstext == '':
	    return HttpResponse('your fancy little news post needs a news post, please type news into your news')
	else:
	    addnews = newsitem(user_name=username, news_title=title, news_body=newstext, pub_date=now, receiver_name=receiver)
	    addnews.save()
	    return homepage(request)
    else:
	return index(request)
Beispiel #18
0
def wipedrives(request):
    if request.user.is_authenticated():
        username = request.user.username
	hddlist = []
	remotepass = "******"
	wipestring = "sudo dcfldd pattern=00 "
	for i in range(98, 122):
            hddletter = chr(i)
            hdd = subprocess.Popen(remotepass + "ls /sys/block | grep sd%s" %hddletter, stdout=subprocess.PIPE, shell=True)
            hdd = hdd.stdout.read().strip()
            if hdd != '':
                hddserial = subprocess.Popen(remotepass + "sudo smartctl -a /dev/%s | grep 'Serial Number'" %hdd, stdout=subprocess.PIPE, shell=True)
                hddserial = hddserial.stdout.read()[14:].strip()
                if hddserial != 'WD-WCASYD980519':
                    wipestring = wipestring + "of=/dev/%s " %hdd
	subprocess.call(remotepass + wipestring, shell=True)
	return render(request, 'drivetool/wipe.html',
		     {"username":username,
		     })
    else:
	return index(request)
Beispiel #19
0
def cleandrives(request):
    if request.user.is_authenticated():
        username = request.user.username
	remotepass = "******"
	for i in range(98, 122):
            hddletter = chr(i)
            hdd = subprocess.Popen(remotepass + "ls /sys/block | grep sd%s" %hddletter, stdout=subprocess.PIPE, shell=True)
            hdd = hdd.stdout.read().strip()
            if hdd != '':
                cleanstring = "sudo dcfldd pattern=00 bs=512 count=1024 of=/dev/%s &" %hdd
                blockcount = subprocess.Popen(remotepass + "sudo blockdev --getsz /dev/%s" %hdd, stdout=subprocess.PIPE, shell=True)
                blockcount = blockcount.stdout.read().strip()
                blockcount = int(blockcount)
                blockcount = blockcount - 2048
                raidstring = "sudo dcfldd pattern=00 bs=512 count=2048 seek=%s of=/dev/%s &" %(blockcount, hdd)
                subprocess.call(remotepass + cleanstring, shell=True)
                subprocess.call(remotepass + raidstring, shell=True)
	return render(request, 'drivetool/clean.html',
		     {"username":username,
		     })
    else:
	return index(request)
Beispiel #20
0
def scandrives(request):
    if request.user.is_authenticated():
	username = request.user.username
	harddrivelist = []
	remotepass = "******"
	for i in range(98, 122):
	    hddletter = chr(i)
	    hdd = subprocess.Popen(remotepass + "ls /sys/block | grep sd%s" %hddletter, shell=True, stdout=subprocess.PIPE)
	    hdd = hdd.stdout.read().strip()
	    if hdd != '':
		hddinfo = subprocess.Popen(remotepass + "sudo smartctl -a /dev/%s" %hdd, shell=True, stdout=subprocess.PIPE)
		hddinfo = hddinfo.stdout.read().splitlines()
		hddmodel = hddinfo[5]
		hddmodel = "Model" + hddmodel[12:]
		hddserial = hddinfo[6]
		hddserial = "Serial" + hddserial[13:]
		hddhours = hddinfo[62]
		hddhours = hddhours[-11:].strip() + " hours on"
		hddsmart = hddinfo[19]
		hddsmart = hddsmart[-7:].strip()
		hddlocation = subprocess.Popen(remotepass + "file /sys/block/%s" %hdd, stdout=subprocess.PIPE, shell=True)
		hddlocation = hddlocation.stdout.read()[-20:-18].strip()
		hddlocation = locator(hddlocation)
		if hddsmart != 'PASSED':
		    hddsmart = 'FAILED SMART TEST'
		else:
		    hddsmart = 'PASSED SMART TEST'
		currenthdd = harddrive(hdd, hddmodel, hddserial, hddhours, hddsmart, hddlocation)
		harddrivelist.append(currenthdd)
		harddrivelist.sort(key=lambda x: x.location)
		harddrivelist = layoutbuilder(harddrivelist)
	return render(request, 'drivetool/drives.html',
		     {"hddlist": harddrivelist,
		      "username": username,
		     })
    else:
	return index(request)
Beispiel #21
0
 def test_home_page_returns_correct_html(self):
     request = HttpRequest()
     response = index(request)
     expected_html = render_to_string('index.html')
     self.assertEqual(response.content.decode(), expected_html)
Beispiel #22
0
def changepassword(request):
    if request.user.is_authenticated():
	user = request.user
	return render(request, 'edituser/changepassword.html')
    else:
	return index(request)