Skip to content

Instantly share code, notes, and snippets.

@edsion1107
edsion1107 / demo.py
Created May 22, 2019 06:59
通过python调用浏览器,打开一个本地html
#!/usr/bin/env python
# encoding: utf-8
"""
@author: edsion
@file: demo.py
@time: 2019-05-22 14:50
当前工程目录结构:
.
@edsion1107
edsion1107 / device.py
Created April 1, 2019 01:47
一个插件化的简单示例。缺点:动态加载导致没有代码提示
class Device(Serial, Transport):
INSTALL_RESULT_PATTERN = r"(Success|Failure|Error)\s?(.*)"
UNINSTALL_RESULT_PATTERN = r"(Success|Failure.*|.*Unknown package:.*)"
def __new__(cls, *args, **kwargs):
# s = importlib.import_module('.__init__', ['plugins'])
p = Path(__file__).parent.joinpath('plugins/dumpsys.py')
# s = importlib.util.spec_from_file_location('plugins', submodule_search_locations=[p])
s = importlib.util.find_spec('.dumpsys', 'src.tmd.common.adb.plugins')
@edsion1107
edsion1107 / check_js_error_by_webdriver
Last active March 27, 2019 09:28
通过webdrvier(chromedriver)检测JS ERROR——页面中有无JS错误。与静态代码检查相比,可以发现运行中的异常。
#!/usr/bin/env python
# encoding: utf-8
"""
@author: edsion
@file: 3.py
@time: 2019-03-26 19:42
"""
import csv
import json
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>demo</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<img id="screenshot" src="" hidden>
<div class="shared">
import requests
import time
from urllib.parse import unquote
def index(request):
data = {'service': 'create_activate_member', 'version': '1.0', 'request_time': int(time.time()), 'partner_id': '200029043446',
'_input_charset': 'UTF-8', 'sign_type': 'RSA', 'sign_version': '1.0', 'encrypt_version': '1.0',
'identity_id': '0401113818', 'identity_type': 'UID', 'client_ip': '1.1.1.1'}
print(unquote(requests.post('https://gate.pay.sina.com.cn/mgs/gateway.do', data={'data':data}).text))
return HttpResponse('index')
import os
import logging
from logging.handlers import RotatingFileHandler
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
fmt = logging.Formatter("%(asctime)s %(levelname)-7s %(module)10s:%(lineno)-4s %(message)s", "%H:%M:%S")
sh = logging.StreamHandler()
sh.setFormatter(fmt)
@edsion1107
edsion1107 / python_self_lock.py
Created March 11, 2017 10:49
python只允许启动一个实例的代码
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Created by edsion on 2017/3/10
import fcntl, sys, time, os
pidfile = 0
def ApplicationInstance():