How to use delete_partner method in localstack

Best Python code snippet using localstack_python

server_business.py

Source:server_business.py Github

copy

Full Screen

1#!/usr/bin/python2# -*- coding: utf-8 -*-3"""4服务器相关操作5"""6from ldsg_admin.common.mysql import get_connection, connection7from ldsg_admin.model import Server, ServerPartnerList, Partner8from ldsg_admin.common.server_util import str_to_dbconfig9def add_server(server_info):10 server = Server()11 for k, v in server_info.iteritems():12 setattr(server, k, v)13 server.persist()14 15def delete_server(sid):16 server = Server()17 server.id = sid18 server.is_del = 1 19 server.persist()20def get_server_list(page, pagesize, server_zone):21 return Server.paging(page, pagesize, condition="is_del=0 and server_zone=%s" % server_zone, order="open_time asc")22def get_all_server_list():23 return Server.query(condition="is_del=0")24def get_server_id_by_sid(sid):25 server = Server.load(id=sid)26 if server:27 return server.server_id28def get_server(server_id):29 return Server.load(server_id=server_id)30def get_server_db_connect(sid=None, server_id=None): 31 if sid:32 server = Server.load(id=sid)33 else:34 server = Server.load(server_id=server_id)35 36 db_connect = server.db_connect37 return str_to_dbconfig(db_connect)38def fix():39 server_list = get_all_server_list()40 for server in server_list:41 db_config = str_to_dbconfig(server.db_connect)42 connect = get_connection(db_config)43 cursor = connect.cursor()44 try:45 reg_time = cursor.fetchone("select reg_time from (select reg_time from user order by reg_time asc limit 500)d order by reg_time desc limit 1")["reg_time"]46 print server.server_id, reg_time47 server.open_time = reg_time48 server.persist()49 finally:50 cursor.close()51 52def get_server_partner_list(server_id):53 """获取服务器合作商列表"""54 return ServerPartnerList.query(condition="server_id='%s'" % server_id, order="partner_id desc")55def set_server_partner_list(server_id, server_zone, partner_ids):56 server_partner_list = get_server_partner_list(server_id)57 delete_partner = []58 59 partner_id_set = set()60 partner_id_list = partner_ids.split(",")61 #增加的parnter62 params = []63 for partner_id in partner_id_list:64 partner_id_set.add(partner_id)65 params.append([partner_id, ])66 67 for server_partner in server_partner_list:68 if server_partner.partner_id not in partner_id_set:69 partner = Partner.load(partner_id=server_partner.partner_id)70 if partner.server_zone != server_zone:71 continue72 delete_partner.append(server_partner.partner_id)73 74 cursor = connection.cursor()75 try:76 if delete_partner:77 cursor.execute("delete from server_partner_list where server_id = '%s' and partner_id in (%s)" % (server_id, ",".join(delete_partner)))78 sql = "insert ignore into server_partner_list(server_id, partner_id, created_time) values('%s', %%s, now())" % server_id79 cursor.executemany(sql, params)80 finally:81 cursor.close()82 83def get_partner_server_list(partner_id):84 85 sql = """select b.server_id, b.server_name, b.server_status, b.open_time, b.server_port from server_partner_list a 86 left join server b on a.server_id = b.server_id where a.partner_id = %s order by b.open_time asc """87 88 cursor = connection.cursor()89 try:90 return cursor.fetchall(sql, [partner_id, ])91 finally:92 cursor.close()93 94if __name__ == '__main__':95 pass...

Full Screen

Full Screen

urls.py

Source:urls.py Github

copy

Full Screen

1from django.urls import path2from . import views3app_name = 'blogs'4urlpatterns = [5 path("",views.home,name='home'),6 path("about",views.AboutView.as_view(),name='about'),7 path("contact",views.ContactView.as_view(),name='contact'),8 path('devis/', views.devis, name='devis'),9 path('blog/',views.PostListView.as_view(),name='post_list'),10 path('blog/<int:pk>/',views.PostDetailView.as_view(),name='post_detail'),11 path('blog/create/', views.CreatePostView.as_view(), name='create_post'),12 path('blog/<int:id>/delete_post/', views.delete_post, name='delete_post'),13 path('blog/<int:id>/delete_partner/', views.delete_partner, name='delete_partner'),14 path('blog/<int:id>/delete_doc/', views.delete_doc, name='delete_doc'),15 path('blog/update_post/<int:pk>', views.UpdatePostView.as_view(), name='update_post'),16 path('blog/update_partner/<int:pk>', views.UpdatePartnerView.as_view(), name='update_partner'),17 path('blog/update_doc/<int:pk>', views.UpdateDocView.as_view(), name='update_doc'),18 path('blog/add_categorie/', views.AddCategorieView.as_view(), name='add_categorie'),19 path('blog/add_doc/', views.AddDocsView.as_view(), name='add_doc'),20 path('blog/add_partner/', views.AddPartnerView.as_view(), name='add_partner'),21 path('blog/categorie/<str:cats>/', views.sameCategorieList, name='same_categorie_list'),22 path('activite/', views.activiteListView, name='activite'),23 path('etudes_au_niger/', views.etudesListView, name='etudes'),24 path('partnaires/', views.PartnerListView.as_view(), name='partners'),25 path('documents/', views.DocsListView.as_view(), name='documents'),26 path('blog/categorie_list/', views.categorieListView, name='categorie_list'),27 path('blog/like/<int:pk>', views.like_view, name='like_view'),28 path('blog/<int:pk>/add_comment/',views.AddCommentView.as_view(), name ='add_comment_section'),29 path('blog/<int:pk>/author_profile', views.showProfileView.as_view(), name='showProfileView')30 ...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful