Best Python code snippet using localstack_python
set_proxy.py
Source:set_proxy.py
...35 bubble.startBubble('GetProxy', u'è¿æ¥æå¡å¨å¼å¸¸ï¼è¯·ä¿æç½ç»ç
é', 3)36 sys.exit(0)373839def modify_hosts():40 os.system(r'"%s\modify_hosts.bat"' % curr_path)414243def modify_shortcut_hosts():44 global carrier45 if not status:46 # å建快æ·æ¹å¼47 subprocess.call(["Wscript.exe", "//E:JScript", curr_path + "\\create_shortcut.js"], shell=False)48 # ä¿®æ¹hosts49 modify_hosts()50 else:51 with open(data_file_path, mode='r') as read_file:52 carrier = read_file.read()535455def get_min_server(server):56 # get min_delay_server57 global status58 delay = []59 for s in server:60 try:61 d = ping.do_one(s, timeout=2, psize=64)62 delay.append(2 if d is None else d)63 except:
...
views.py
Source:views.py
...61 }62 return render(request, 'inventory/hosts/add_hosts.html', context)63@database_error_decorator64@login_required(login_url='/login/')65def modify_hosts(request):66 fields = Hosts.objects.all().values()67 if request.method == 'POST':68 if request.POST.get('hostname') != '' and request.POST.get('old_hostname') != request.POST.get(69 'hostname'):70 context = {71 'form_error': True,72 'fields': fields,73 }74 return render(request, 'inventory/hosts/modify_hosts.html', context)75 elif request.POST.get('action') == 'modify':76 # How to change a django QueryDict to Python Dict?77 # http://stackoverflow.com/questions/13349573/how-to-change-a-django-querydict-to-python-dict78 form_dict = request.POST.dict() # myDict = dict(queryDict.iterlists())79 form_dict_key_list = form_dict.keys()...
urls.py
Source:urls.py
1"""kissops URL Configuration2The `urlpatterns` list routes URLs to views. For more information please see:3 https://docs.djangoproject.com/en/1.9/topics/http/urls/4Examples:5Function views6 1. Add an import: from my_app import views7 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')8Class-based views9 1. Add an import: from other_app.views import Home10 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')11Including another URLconf12 1. Import the include() function: from django.conf.urls import url, include13 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))14"""15from django.conf import settings16from django.conf.urls import include, url17from django.conf.urls.static import static18from django.contrib import admin19from django.views.generic.base import RedirectView20from inventory.host.views import list_hosts, add_hosts, modify_hosts21from itoms.views import post, test_json, itoms_app, django_admin, app2question22from kissops import views23from login.views import login, logout, register, profile, management, reset_password, forget_password24admin.autodiscover()25urlpatterns = [26 url(r'^favicon.ico$', RedirectView.as_view(url=getattr(settings, 'FAVICON_PATH'))),27 url(r'^robots.txt$', RedirectView.as_view(url=getattr(settings, 'ROBOTS_PATH'))),28 url(r'^admin/', admin.site.urls),29 url(r'^api/', include('api.urls')),30 url(r'^management$', management, name='management'),31 url(r'^$', views.index, name='index'),32 url(r'^login/$', login, name='login'),33 url(r'^logout/$', logout, name='logout'),34 url(r'^register/$', register, name='register'),35 url(r'^profile/$', profile, name='profile'),36 url(r'^forget_password/$', forget_password, name='forget_password'),37 url(r'^reset_password/$', reset_password, name='reset_password'),38 url(r'^list_hosts/$', list_hosts, name='list_hosts'),39 url(r'^add_hosts/$', add_hosts, name='add_hosts'),40 url(r'^modify_hosts/$', modify_hosts, name='modify_hosts'),41 url(r'^post/$', post, name='post'),42 url(r'^json/$', test_json, name='test_json'),43 url(r'^itoms_app/$', itoms_app, name='itoms_app'),44 url(r'^django_admin/$', django_admin, name='django_admin'),45 url(r'^app2question/$', app2question, name='app2question'),...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!