This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def get_cur_info(): | |
_ = sys._getframe() | |
return (_.f_code.co_name, _.f_back.f_lineno) # funcname, lineno |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculate(last_time, current_time): | |
time_delta = \ | |
datetime.datetime.strptime(current_time, '%M:%S.%f') -\ | |
datetime.datetime.strptime(last_time, '%M:%S.%f') | |
return str(time_delta)[2:-4] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import listdir | |
from os.path import splitext, basename, isfile, isdir, join | |
def GetFileList(dir, fileList): | |
newDir = dir | |
if isfile(dir): | |
fileList.append(dir.decode('utf-8')) | |
elif isdir(dir): | |
for s in listdir(dir): | |
# 如果需要忽略某些文件夹,使用以下代码 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[mail] | |
smtp_server = smtp.your-service.com | |
to_addr = [email protected] | |
from_addr = [email protected] | |
nickname = nick-name | |
password = your-password | |
prefix = subject-prefix | |
port = 25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os.path import exists | |
if exists(r'/home/test.txt'): | |
shutil.copyfile(r'/home/test.txt', r'/home/root/') | |
else: | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
""" | |
""" | |
import pypyodbc | |
__author__ = "Jux.Liu" | |
# pypyodbc.lowercase = False | |
db_file = r'D:\att2000.mdb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding:utf-8 -*- | |
import pip | |
from subprocess import call | |
for dist in pip.get_installed_distributions(): | |
call("pip2 install --upgrade {}".format(dist.project_name), shell=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
from uuid import getnode as get_mac, UUID | |
macaddr=UUID(int=get_mac()).hex[-12:].upper() # FFFFFFFFFFFF | |
return(":".join([macaddr[e:e+2] for e in range(0,11,2)])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
import pycurl | |
def Upload(file_name, url): | |
pc = pycurl.Curl() | |
pc.setopt(pycurl.URL, url) # URL | |
pc.setopt(pycurl.HTTPPOST, | |
[('logfile', (pc.FORM_FILE, file_name,))]) # {'logfile': xxx} | |
pc.perform() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
import mmap | |
import urllib2 | |
def Upload(fname, url): | |
f = open(fname, 'rb') | |
mmapped_file_as_string = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) | |
# Do the request |
OlderNewer