本文整理汇总了Python中userprofile.views._log_user_activity函数的典型用法代码示例。如果您正苦于以下问题:Python _log_user_activity函数的具体用法?Python _log_user_activity怎么用?Python _log_user_activity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_log_user_activity函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: logs
def logs(request):
print '-- system logs:', request.user
user = request.user
profile = Profile.objects.get(user=request.user)
secret = profile.secret
ip = request.META['REMOTE_ADDR']
_log_user_activity(profile,"click","/logs/","logs",ip=ip)
user = request.user
user.last_login = datetime.datetime.now()
user.save()
servers = mongo.servers.find({'secret':secret,})
activities = mongo.activity.find({'secret':secret,}).sort("_id",pymongo.DESCENDING)
activities = activities.limit(10)
return render_to_response(
'logs.html',
{
'request':request,
'secret':profile.secret,
'servers':servers,
'activities':activities,
},
context_instance=RequestContext(request),
)
开发者ID:Nazmul56,项目名称:Cloudly,代码行数:29,代码来源:views.py
示例2: admin
def admin(request):
print "-- admin page:"
if not request.user.is_staff:
return HttpResponseRedirect("/")
print request.user
users = Profile.objects.all().order_by("-last_seen")
profile = Profile.objects.get(user=request.user)
user = request.user
user.last_login = datetime.datetime.now()
user.save()
users = Profile.objects.all().order_by("-pk")
ip = request.META["REMOTE_ADDR"]
_log_user_activity(profile, "click", "/admin/", "admin", ip=ip)
return render_to_response(
"admin.html",
{"users": users, "files": [], "profile": profile, "request": request},
context_instance=RequestContext(request),
)
开发者ID:OndrejKopal,项目名称:cloudly,代码行数:26,代码来源:views.py
示例3: home
def home(request):
if not request.user.is_authenticated():
print '-- web:'
return render_to_response('web.html', {'request':request,}, context_instance=RequestContext(request))
print '-- dashboard:'
print request.user
user = request.user
user.last_login = datetime.datetime.now()
user.save()
profile = userprofile.objects.get(user=request.user)
secret = profile.secret
ip = request.META['REMOTE_ADDR']
_log_user_activity(profile,"click","/","home",ip=ip)
is_updating = False
try:
vms_cache = Cache.objects.get(user=request.user)
vms_response = vms_cache.vms_response
vms_response = base64.b64decode(vms_response)
vms_response = pickle.loads(vms_response)
vms_cached_response = vms_response
vms_cached_response['last_seen'] = vms_cache.last_seen
is_updating = vms_cache.is_updating
except: vms_cached_response = None
return render_to_response('dashboard.html', {'is_updating':is_updating,'vms_cached_response':vms_cached_response,}, context_instance=RequestContext(request))
开发者ID:kotvat,项目名称:cloudly,代码行数:32,代码来源:views.py
示例4: incidents
def incidents(request):
print '-- system logs:', request.user
user = request.user
profile = Profile.objects.get(user=request.user)
secret = profile.secret
ip = request.META['REMOTE_ADDR']
_log_user_activity(profile,"click","/logs/","logs",ip=ip)
user = request.user
user.last_login = datetime.datetime.now()
user.save()
notifs_counter = 0
active_service_statuses = mongo.active_service_statuses
active_service_statuses_data = active_service_statuses.find({"$and": [{"secret": secret}, {"current_overall_status": {"$ne": "OK"}}]})
notifs_counter = active_service_statuses_data.count()
unknown_notifs = active_service_statuses.find({"secret":secret,"current_overall_status":"UNKNOWN"})
warning_notifs = active_service_statuses.find({"secret":secret,"current_overall_status":"WARNING"})
critical_notifs = active_service_statuses.find({"secret":secret,"current_overall_status":"CRITICAL"})
return render_to_response('incidents.html', {'request':request,'notifs_counter':notifs_counter,'active_service_statuses':active_service_statuses_data,'unknown_notifs':unknown_notifs,'warning_notifs':warning_notifs,'critical_notifs':critical_notifs,'profile':profile,}, context_instance=RequestContext(request))
开发者ID:brianjking,项目名称:cloudly,代码行数:25,代码来源:views.py
示例5: home
def home(request):
if not request.user.is_authenticated():
print '-- web:'
random_motto = CLOUDLY_MOTTOS[ random.randint(0,len(CLOUDLY_MOTTOS)-1) ]
return render_to_response(
'current-web.html',
{'random_motto':random_motto,}
)
print '-- dashboard:'
print request.user
user = request.user
user.last_login = datetime.datetime.now()
user.save()
profile = userprofile.objects.get(user=request.user)
secret = profile.secret
ip = request.META['REMOTE_ADDR']
try:
_log_user_activity(profile,"click","/","home",ip=ip)
except: pass
is_updating = False
try:
vms_cache = Cache.objects.get(user=request.user)
vms_response = vms_cache.vms_response
vms_response = base64.b64decode(vms_response)
vms_response = pickle.loads(vms_response)
vms_cached_response = vms_response
vms_cached_response['last_seen'] = vms_cache.last_seen
is_updating = vms_cache.is_updating
except: vms_cached_response = None
servers = mongo.servers.find({'secret':profile.secret,}).sort('_id',-1);
servers_tags = {}
for server in servers:
if 'tags' in server:
for tag_category in server['tags']:
if(not servers_tags.has_key(tag_category)):
servers_tags[tag_category] = [];
for inner_tag in server['tags'][tag_category]:
if(not inner_tag[0] in servers_tags[tag_category]):
servers_tags[tag_category].append(inner_tag[0])
return render_to_response(
'dashboard.html',
{
'servers_tags':servers_tags,
'is_updating':is_updating,
'vms_cached_response':vms_cached_response,
},
context_instance=RequestContext(request)
)
开发者ID:xsvs,项目名称:cloudly,代码行数:59,代码来源:views.py
示例6: server_view
def server_view(request, hwaddr):
print '-- server_view'
print request.user
user = request.user
profile = userprofile.objects.get(user=request.user)
ip = request.META['REMOTE_ADDR']
_log_user_activity(profile,"click","/server/"+hwaddr,"server_view",ip=ip)
hwaddr_orig = hwaddr
hwaddr = hwaddr.replace('-',':')
server = mongo.servers.find_one({'secret':profile.secret,'uuid':hwaddr,})
server_status = "Running"
if((datetime.datetime.utcnow()-server['last_seen']).total_seconds()>20):
server_status = "Stopped"
if((datetime.datetime.utcnow()-server['last_seen']).total_seconds()>1800):
server_status = "Offline"
try:
uuid = server['uuid']
except:
return HttpResponse("access denied")
disks_usage_ = []
#disks_usage = mongo.disks_usage.find({'uuid':uuid,}).sort('_id',-1).limit(60)
#for i in disks_usage: disks_usage_.append(i)
disks_usage = disks_usage_
networking_ = []
#networking = mongo.networking.find({'uuid':uuid,}).sort('_id',-1).limit(60)
#for i in networking: networking_.append(i)
networking = networking_
mem_usage_ = []
#mem_usage = mongo.memory_usage.find({'uuid':uuid,}).sort('_id',-1).limit(60)
#for i in mem_usage: mem_usage_.append(i)
mem_usage = mem_usage_
loadavg_ = []
#loadavg = mongo.loadavg.find({'uuid':uuid,}).sort('_id',-1).limit(60)
#for i in loadavg: loadavg_.append(i)
loadavg = loadavg_
activity = mongo.activity.find({'uuid':uuid,}).sort('_id',-1).limit(3)
disks = []
disks_ = server[u'disks_usage']
for disk in disks_:
if not disk[5] in disks:
disks.append(disk[5])
return render_to_response('server_detail.html', {'secret':profile.secret,'hwaddr':hwaddr,'hwaddr_orig':hwaddr_orig,'server':server,'server_status':server_status,'disks_usage':disks_usage,'disks':disks,'mem_usage':mem_usage,'loadavg':loadavg,'networking':networking,'activity':activity,}, context_instance=RequestContext(request))
开发者ID:step1profit,项目名称:cloudly,代码行数:57,代码来源:views.py
示例7: download_agent
def download_agent(request):
print "-- download agent:"
server_url = request.build_absolute_uri("/")
api_server_url = server_url
api_server_url = api_server_url.replace("http://", "").replace("https://", "")
api_server_url = api_server_url.split(":")[0].replace("/", "")
api_server_url = api_server_url + ":5001"
if "projectcloudly.com" in api_server_url:
api_server_url = "api.projectcloudly.com:5001"
ip = request.META["REMOTE_ADDR"]
try:
profile = userprofile.objects.get(user=request.user)
except:
pass
print "server_url", server_url
print "api_server_url", api_server_url
if request.GET:
try:
xuuid = request.GET["xuuid"]
profile = userprofile.objects.get(agent_hash=xuuid)
except:
return HttpResponseForbidden()
_log_user_activity(profile, "download", "/download/agent/", "download_agent", ip=ip)
agent_code = ""
for line in open("agent.py"):
if 'SECRET = ""' in line:
agent_code += 'SECRET = "' + profile.secret + '"\n'
continue
if 'API_SERVER = ""' in line:
agent_code += 'API_SERVER = "' + api_server_url + '"\n'
continue
agent_code += line
return HttpResponse(agent_code)
try:
agent_download_url = server_url + "download/agent?xuuid=" + profile.agent_hash
print "agent_download_url", agent_download_url
except:
return HttpResponseRedirect("https://raw.githubusercontent.com/jparicka/cloudly/master/agent.py")
return render_to_response(
"agent_download.html",
{"request": request, "profile": profile, "agent_download_url": agent_download_url},
context_instance=RequestContext(request),
)
开发者ID:pguso,项目名称:Cloudly,代码行数:56,代码来源:views.py
示例8: welcome
def welcome(request):
print "-- welcome page:", request.user
ip = request.META["REMOTE_ADDR"]
profile = userprofile.objects.get(user=request.user)
_log_user_activity(profile, "click", "/welcome/", "welcome", ip=ip)
print request.user
return render_to_response("welcome.html", locals(), context_instance=RequestContext(request))
开发者ID:pguso,项目名称:Cloudly,代码行数:10,代码来源:views.py
示例9: user_activity_report
def user_activity_report(request, user_id):
print "-- admin report user activity", user_id
if not request.user.is_staff:
return HttpResponseRedirect("/")
print request.user
profile = Profile.objects.get(user=request.user)
u = User.objects.get(pk=user_id)
ip = request.META["REMOTE_ADDR"]
_log_user_activity(profile, "click", "/admin/user/" + str(user_id) + "/report/", "user_activity_report", ip=ip)
user_activity = Activity.objects.filter(user=u).order_by("-pk")
user_activity_clicks = Activity.objects.filter(user=u, activity="click").order_by("-pk")
user_activity_other = Activity.objects.filter(user=u).filter(~Q(activity="click")).order_by("-pk")
user_profile = Profile.objects.get(user=u)
try:
vms_cache = Cache.objects.get(user=u)
vms_response = vms_cache.vms_response
vms_response = base64.b64decode(vms_response)
vms_response = pickle.loads(vms_response)
vms_cached_response = vms_response
# vms_cached_response['last_seen'] = vms_cache.last_seen
except:
vms_cached_response = None
servers = mongo.servers.find({"secret": user_profile.secret}).sort("_id", -1)
user = request.user
user.last_login = datetime.datetime.now()
user.save()
return render_to_response(
"admin_user_report.html",
{
"u": u,
"vms_cached_response": vms_cached_response,
"user_profile": user_profile,
"user_files": [],
"user_activity": user_activity,
"user_activity_clicks": user_activity_clicks,
"user_activity_other": user_activity_other,
"profile": profile,
"servers": servers,
},
context_instance=RequestContext(request),
)
开发者ID:OndrejKopal,项目名称:cloudly,代码行数:53,代码来源:views.py
示例10: download_agent
def download_agent(request):
print '-- download agent:'
server_url = request.build_absolute_uri('/')
api_server_url = server_url
api_server_url = api_server_url.replace('http://','').replace('https://','')
api_server_url = api_server_url.split(':')[0].replace('/','')
api_server_url = api_server_url + ":5001"
if('projectcloudly.com' in api_server_url):
api_server_url = "api.projectcloudly.com:5001"
ip = request.META['REMOTE_ADDR']
try:
profile = userprofile.objects.get(user=request.user)
except: pass
print 'server_url', server_url
print 'api_server_url', api_server_url
if(request.GET):
try:
xuuid = request.GET['xuuid']
profile = userprofile.objects.get(agent_hash=xuuid)
except:
return HttpResponseForbidden()
_log_user_activity(profile,"download","/download/agent/","download_agent",ip=ip)
agent_code = ""
for line in open('agent.py'):
if("SECRET = \"\"" in line):
agent_code += "SECRET = \""+profile.secret+"\"\n"
continue
if("API_SERVER = \"\"" in line):
agent_code += "API_SERVER = \""+api_server_url+"\"\n"
continue
agent_code += line
return HttpResponse(agent_code)
try:
agent_download_url = server_url + "download/agent?xuuid="+profile.agent_hash
print 'agent_download_url', agent_download_url
except:
return HttpResponseRedirect("https://raw.githubusercontent.com/ProjectCloudly/Cloudly/master/agent.py")
return render_to_response('agent_download.html', {'request': request, 'profile':profile,'agent_download_url':agent_download_url,}, context_instance=RequestContext(request))
开发者ID:KitJacky,项目名称:Cloudly,代码行数:52,代码来源:views.py
示例11: incidents
def incidents(request):
print '-- incidents:', request.user
user = request.user
profile = Profile.objects.get(user=request.user)
secret = profile.secret
ip = request.META['REMOTE_ADDR']
_log_user_activity(profile,"click","/incidents/","incidents",ip=ip)
user = request.user
user.last_login = datetime.datetime.now()
user.save()
servers = mongo.servers.find({'secret':profile.secret},{'uuid':1,'name':1}).sort('_id',-1);
serversNames = {}
for server in servers:
serversNames[server['uuid']] = server['name']
active_service_statuses = mongo.active_service_statuses
active_notifs = {}
notifs_types = ["CRITICAL","WARNING","UNKNOWN",]
for notifs_type in notifs_types:
active_notifs[notifs_type] = []
notifs = active_service_statuses.find({"secret":secret,"current_overall_status":notifs_type})
for notif in notifs:
notif.update({'name':serversNames[notif['server_id']]})
server = mongo.servers.find_one({'uuid':notif['server_id'],})
if((datetime.datetime.now()-server['last_seen']).total_seconds()<20):
active_notifs[notifs_type].append(notif)
servers = []
for server in mongo.servers.find({"secret":profile.secret,}):
servers.append(server)
return render_to_response(
'incidents.html',
{
'request':request,
'secret':profile.secret,
'servers': servers,
'active_notifs':active_notifs
},
context_instance=RequestContext(request),
)
开发者ID:ampg99,项目名称:cloudly,代码行数:50,代码来源:views.py
示例12: investors
def investors(request):
print '-- investors page:', request.user
ip = request.META['REMOTE_ADDR']
try:
profile = userprofile.objects.get(user=request.user)
_log_user_activity(profile,"click","/investors/","welcome",ip=ip)
except:
return HttpResponseRedirect("https://github.com/jparicka/cloudly")
print request.user
return render_to_response('investors.html', locals(), context_instance=RequestContext(request))
开发者ID:coredevelopers,项目名称:cloudly,代码行数:14,代码来源:views.py
示例13: credits
def credits(request):
try:
print "-- credits page:", request.user
except:
print "-- credits page: anonymous"
ip = request.META["REMOTE_ADDR"]
try:
profile = userprofile.objects.get(user=request.user)
_log_user_activity(profile, "click", "/credits/", "credits", ip=ip)
except:
return HttpResponseRedirect("https://github.com/jparicka/cloudly")
print request.user
return render_to_response("credits.html", {"request": request}, context_instance=RequestContext(request))
开发者ID:pguso,项目名称:Cloudly,代码行数:16,代码来源:views.py
示例14: incidents
def incidents(request):
print '-- system logs:', request.user
user = request.user
profile = Profile.objects.get(user=request.user)
secret = profile.secret
ip = request.META['REMOTE_ADDR']
_log_user_activity(profile,"click","/logs/","logs",ip=ip)
user = request.user
user.last_login = datetime.datetime.now()
user.save()
return render_to_response('incidents.html', {'profile':profile,}, context_instance=RequestContext(request))
开发者ID:kotvat,项目名称:cloudly,代码行数:16,代码来源:views.py
示例15: credits
def credits(request):
try:
print '-- credits page:', request.user
except:
print '-- credits page: anonymous'
ip = request.META['REMOTE_ADDR']
try:
profile = userprofile.objects.get(user=request.user)
_log_user_activity(profile,"click","/credits/","credits",ip=ip)
except:
return HttpResponseRedirect("/")
print request.user
return render_to_response('credits.html', {'request':request,}, context_instance=RequestContext(request))
开发者ID:KitJacky,项目名称:Cloudly,代码行数:18,代码来源:views.py
示例16: user_activity_report
def user_activity_report(request, user_id):
print '-- admin report user activity', user_id
#if not request.user.is_superuser:
# print 'anonymous'
# return HttpResponseRedirect("/")
print request.user
profile = Profile.objects.get(user=request.user)
u = User.objects.get(pk=user_id)
ip = request.META['REMOTE_ADDR']
_log_user_activity(profile,"click","/admin/user/"+str(user_id)+"/report/","user_activity_report",ip=ip)
user_activity = Activity.objects.filter(user=u).order_by('-pk')
user_activity_clicks = Activity.objects.filter(user=u,activity="click").order_by('-pk')
user_activity_other = Activity.objects.filter(user=u).filter(~Q(activity="click")).order_by('-pk')
user_profile = Profile.objects.get(user=u)
try:
vms_cache = Cache.objects.get(user=u)
vms_response = vms_cache.vms_response
vms_response = base64.b64decode(vms_response)
vms_response = pickle.loads(vms_response)
vms_cached_response = vms_response
#vms_cached_response['last_seen'] = vms_cache.last_seen
except: vms_cached_response = None
servers = mongo.servers.find({'secret':user_profile.secret,}).sort('_id',-1)
import datetime
user = request.user
user.last_login = datetime.datetime.now()
user.save()
return render_to_response('admin_user_report.html', {'u':u,'vms_cached_response':vms_cached_response,'user_profile':user_profile,'user_files':[],'user_activity':user_activity,'user_activity_clicks':user_activity_clicks,'user_activity_other':user_activity_other,'profile':profile,'servers':servers,}, context_instance=RequestContext(request))
开发者ID:cengjing,项目名称:cloudly,代码行数:41,代码来源:views.py
示例17: control_aws_vm
def control_aws_vm(request, vm_name, action):
print request.user
user = request.user
profile = userprofile.objects.get(user=request.user)
user.last_login = datetime.datetime.now()
user.save()
ip = request.META['REMOTE_ADDR']
_log_user_activity(profile,"click","/aws/"+vm_name+"/"+action+"/","control_aws_vm",ip=ip)
vms_cache = Cache.objects.get(user=user)
vm_cache = vms_cache.vms_response
vm_cache = base64.b64decode(vm_cache)
vm_cache = pickle.loads(vm_cache)[vm_name]
if(vm_cache['user_id']!=request.user.id):
return HttpResponse("access denied")
aws_access_key = profile.aws_access_key
aws_secret_key = profile.aws_secret_key
aws_ec2_verified = profile.aws_ec2_verified
ec2_region = vm_cache['instance']['region']['name']
ec2conn = boto.ec2.connect_to_region(ec2_region,aws_access_key_id=aws_access_key,aws_secret_access_key=aws_secret_key)
if(action=="reboot"):
ec2conn.reboot_instances([vm_name,])
if(action=="start"):
ec2conn.start_instances([vm_name,])
if(action=="stop"):
ec2conn.stop_instances([vm_name,])
if(action=="terminate"):
ec2conn.terminate_instances([vm_name,])
# XXX duplicate, auto-scaling on, auto-scaling off, backup
return HttpResponseRedirect("/")
开发者ID:cengjing,项目名称:cloudly,代码行数:40,代码来源:views.py
示例18: home
def home(request):
if not request.user.is_authenticated():
print '-- web:'
CLOUDLY_MOTTOS = [
"The Power of Now!",
"Relax, it’s going to take no time!",
"Saves you money and resources!",
"Real-time servers monitoring.",
]
return render_to_response('web.html', {'request':request,'CLOUDLY_MOTTOS':CLOUDLY_MOTTOS,}, context_instance=RequestContext(request))
print '-- dashboard:'
print request.user
user = request.user
user.last_login = datetime.datetime.now()
user.save()
profile = userprofile.objects.get(user=request.user)
secret = profile.secret
ip = request.META['REMOTE_ADDR']
_log_user_activity(profile,"click","/","home",ip=ip)
is_updating = False
try:
vms_cache = Cache.objects.get(user=request.user)
vms_response = vms_cache.vms_response
vms_response = base64.b64decode(vms_response)
vms_response = pickle.loads(vms_response)
vms_cached_response = vms_response
vms_cached_response['last_seen'] = vms_cache.last_seen
is_updating = vms_cache.is_updating
except: vms_cached_response = None
return render_to_response('dashboard.html', {'is_updating':is_updating,'vms_cached_response':vms_cached_response,}, context_instance=RequestContext(request))
开发者ID:coredevelopers,项目名称:cloudly,代码行数:38,代码来源:views.py
示例19: admin
def admin(request):
print '-- admin page:'
if not request.user.is_staff:
return HttpResponseRedirect("/")
print request.user
users = Profile.objects.all().order_by('-last_seen')
profile = Profile.objects.get(user=request.user)
import datetime
user = request.user
user.last_login = datetime.datetime.now()
user.save()
users = Profile.objects.all().order_by('-pk')
ip = request.META['REMOTE_ADDR']
_log_user_activity(profile,"click","/admin/","admin",ip=ip)
return render_to_response('admin.html', {'users':users,'files':[],'profile':profile,'request':request,}, context_instance=RequestContext(request))
开发者ID:pguso,项目名称:Cloudly,代码行数:23,代码来源:views.py
示例20: incidents
def incidents(request):
print "-- system logs:", request.user
user = request.user
profile = Profile.objects.get(user=request.user)
secret = profile.secret
ip = request.META["REMOTE_ADDR"]
_log_user_activity(profile, "click", "/logs/", "logs", ip=ip)
user = request.user
user.last_login = datetime.datetime.now()
user.save()
servers = mongo.servers.find({"secret": profile.secret}, {"uuid": 1, "name": 1}).sort("_id", -1)
serversNames = {}
for server in servers:
serversNames[server["uuid"]] = server["name"]
active_service_statuses = mongo.active_service_statuses
active_notifs = {}
notifs_types = ["CRITICAL", "WARNING", "UNKNOWN"]
for notifs_type in notifs_types:
active_notifs[notifs_type] = []
notifs = active_service_statuses.find({"secret": secret, "current_overall_status": notifs_type})
for notif in notifs:
notif.update({"name": serversNames[notif["server_id"]]})
active_notifs[notifs_type].append(notif)
return render_to_response(
"incidents.html",
{"request": request, "secret": profile.secret, "active_notifs": active_notifs},
context_instance=RequestContext(request),
)
开发者ID:xantin,项目名称:cloudly,代码行数:37,代码来源:views.py
注:本文中的userprofile.views._log_user_activity函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论