Best Python code snippet using localstack_python
l_command.py
Source:l_command.py
1#!/usr/bin/env python2#_*_encoding:utf-8_*_3# encoding:utf-84import os,sys5import httplib2,hashlib6http = httplib2.Http()7def l_main(cmd):8 if cmd == 'l_version' :return l_version()9 if cmd == 'l_update' :return l_update()10 if cmd == 'l_pwd' :return l_pwd()11 return False12def l_pwd():13 return sys.path[0]14def l_version():15 return '0.1'16def file_md5(filename):17 f = open(filename, 'a+r')18 return hashlib.md5(f.read()).hexdigest()19def file_write(filename, up_path):20 url = 'http://agent.mangle.starl.com.cn/'+filename21 f = open (up_path, 'w')22 f.write(get_http(url))23 return 124def get_http(url):25 response,content = http.request(url,'GET')26 return content27def l_update():28 update_url = 'http://agent.mangle.starl.com.cn/update.txt'29 content = get_http(update_url)30 update_dict = eval(content)31 update_done = {}32 if update_dict.get('version') == l_version():33 return 'latest'34 else:35 del update_dict['version']36 for up_name, up_md5 in update_dict.items():37 up_path = sys.path[0] + '/' + up_name38 local_file_md5 = file_md5(up_path)39 serve_file_md5 = up_md540 if local_file_md5 != serve_file_md5:41 if file_write(up_name, up_path):42 update_done[up_name] = 'update ok...'43 else:44 update_done[up_name] = 'update no...'45 if update_done:46 return update_done47 else:...
urls.py
Source:urls.py
1from django.urls import path2from . import views3app_name= 'kakeibo'4urlpatterns = [5 path('', views.kakeiboListView.as_view(), name='kakeibo_list'),6 path('kakeibo_create/', views.KakeiboCreateView.as_view(), name='kakeibo_create'),7 path('create_done/', views.create_done, name='create_done'),8 path('update/<int:pk>/',views.KakeiboUpdateView.as_view(), name='kakeibo_update'),9 path('update_done/',views.update_done, name='update_done'),10 path('delete/<int:pk>/',views.KakeiboDeleteView.as_view(),name="kakeibo_delete"),11 path('delete_done',views.delete_done, name='delete_done'),12 path('circle/', views.show_circle_grahp, name='kakeibo_circle'),13 path('line/',views.show_line_grahp, name='kakeibo_line'),...
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!!