ish
*.DS_Store
*.swp
+*.ef
dvwa
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>Ansi 0 Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.0</real>
+ <key>Green Component</key>
+ <real>0.0</real>
+ <key>Red Component</key>
+ <real>0.0</real>
+ </dict>
+ <key>Ansi 1 Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.032882384955883026</real>
+ <key>Green Component</key>
+ <real>0.0</real>
+ <key>Red Component</key>
+ <real>0.98047482967376709</real>
+ </dict>
+ <key>Ansi 10 Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.0</real>
+ <key>Green Component</key>
+ <real>0.85098040103912354</real>
+ <key>Red Component</key>
+ <real>0.0</real>
+ </dict>
+ <key>Ansi 11 Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.0</real>
+ <key>Green Component</key>
+ <real>0.89803922176361084</real>
+ <key>Red Component</key>
+ <real>0.89803922176361084</real>
+ </dict>
+ <key>Ansi 12 Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>1</real>
+ <key>Green Component</key>
+ <real>0.0</real>
+ <key>Red Component</key>
+ <real>0.0</real>
+ </dict>
+ <key>Ansi 13 Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.89803922176361084</real>
+ <key>Green Component</key>
+ <real>0.0</real>
+ <key>Red Component</key>
+ <real>0.89803922176361084</real>
+ </dict>
+ <key>Ansi 14 Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.89803922176361084</real>
+ <key>Green Component</key>
+ <real>0.89803922176361084</real>
+ <key>Red Component</key>
+ <real>0.0</real>
+ </dict>
+ <key>Ansi 15 Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.89803922176361084</real>
+ <key>Green Component</key>
+ <real>0.89803922176361084</real>
+ <key>Red Component</key>
+ <real>0.89803922176361084</real>
+ </dict>
+ <key>Ansi 2 Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.0</real>
+ <key>Green Component</key>
+ <real>0.65098041296005249</real>
+ <key>Red Component</key>
+ <real>0.0</real>
+ </dict>
+ <key>Ansi 3 Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.0</real>
+ <key>Green Component</key>
+ <real>0.60000002384185791</real>
+ <key>Red Component</key>
+ <real>0.60000002384185791</real>
+ </dict>
+ <key>Ansi 4 Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.92527294158935547</real>
+ <key>Green Component</key>
+ <real>0.50906872749328613</real>
+ <key>Red Component</key>
+ <real>0.11661802977323532</real>
+ </dict>
+ <key>Ansi 5 Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.69803923368453979</real>
+ <key>Green Component</key>
+ <real>0.0</real>
+ <key>Red Component</key>
+ <real>0.69803923368453979</real>
+ </dict>
+ <key>Ansi 6 Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.69803923368453979</real>
+ <key>Green Component</key>
+ <real>0.65098041296005249</real>
+ <key>Red Component</key>
+ <real>0.0</real>
+ </dict>
+ <key>Ansi 7 Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.74901962280273438</real>
+ <key>Green Component</key>
+ <real>0.74901962280273438</real>
+ <key>Red Component</key>
+ <real>0.74901962280273438</real>
+ </dict>
+ <key>Ansi 8 Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.40000000596046448</real>
+ <key>Green Component</key>
+ <real>0.40000000596046448</real>
+ <key>Red Component</key>
+ <real>0.40000000596046448</real>
+ </dict>
+ <key>Ansi 9 Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.0</real>
+ <key>Green Component</key>
+ <real>0.0</real>
+ <key>Red Component</key>
+ <real>0.89803922176361084</real>
+ </dict>
+ <key>Background Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.0</real>
+ <key>Green Component</key>
+ <real>0.0</real>
+ <key>Red Component</key>
+ <real>0.0</real>
+ </dict>
+ <key>Bold Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.0</real>
+ <key>Green Component</key>
+ <real>1</real>
+ <key>Red Component</key>
+ <real>0.0</real>
+ </dict>
+ <key>Cursor Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.094117648899555206</real>
+ <key>Green Component</key>
+ <real>1</real>
+ <key>Red Component</key>
+ <real>0.13725490868091583</real>
+ </dict>
+ <key>Cursor Text Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.0940093994140625</real>
+ <key>Green Component</key>
+ <real>0.0</real>
+ <key>Red Component</key>
+ <real>1</real>
+ </dict>
+ <key>Foreground Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.0</real>
+ <key>Green Component</key>
+ <real>1</real>
+ <key>Red Component</key>
+ <real>0.0</real>
+ </dict>
+ <key>Selected Text Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>1</real>
+ <key>Green Component</key>
+ <real>1</real>
+ <key>Red Component</key>
+ <real>1</real>
+ </dict>
+ <key>Selection Color</key>
+ <dict>
+ <key>Blue Component</key>
+ <real>0.019607843831181526</real>
+ <key>Green Component</key>
+ <real>0.22352941334247589</real>
+ <key>Red Component</key>
+ <real>0.031372550874948502</real>
+ </dict>
+</dict>
+</plist>
# Tue Apr 28 15:00:56 2015
# Description: none
# ------------------------------------------------------------------------
+import sys
-while True :
- n = raw_input("Input Decimal: ")
- hexs = "{0:X}".format(int(n))
- print hexs
+def main() :
+ while True :
+ n = 0
+ inputdata = raw_input("> ")
+ if inputdata.lower() == 'quit' :
+ sys.exit()
+
+ try :
+ n = int(inputdata)
+ except ValueError,e :
+ print "ERROR: ", e
+ continue
+
+ hexs = "{0:X} 0x{1:X}".format(n, n)
+ print hexs
+
+
+if __name__ == "__main__" :
+ try :
+ main()
+ except KeyboardInterrupt :
+ print "Bye..."
+ pass
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# ------------------------------------------------------------------------
-# File Name: NetDetector.py
-# Author: AceZhao
-# Copyright (C) 2013 GZRD,Tencent. All Rights Reserved.
-# Fri Mar 29 11:09:56 2013
-# Description: none
-# ------------------------------------------------------------------------
-import os
-import sys
-import socket
-import logging
-import time
-from threading import Timer
-
-gPort = 0xACE
-gSndPktCnt = 0xACE
-gSndDst = ''
-gPktSize = 100
-gSndHz = 100
-gSndDelay = 1
-
-
-logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s %(message)s',
- filename='log.{0}.txt'.format(time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))),
- filemode='w+')
-
-class Storage(dict) :
- def __getattr__(self, key) :
- try :
- return self[key]
- except KeyError, k:
- raise AttributeError, k
-
- def __setattr__(self, key, value) :
- self[key] = value
-
- def __delattr__(self, key) :
- try :
- del self[key]
- except KeyError, k:
- raise AttributeError, k
-
- def __repr__(self) :
- return '<Storage ' + dict.__repr__(self) + '>'
-
-
-class Data(Storage) :
- def __init__(self) :
- self.Sn = 0
- self.size = 0
- self.Data = '0'
-
- def Init(self, sn, size) :
- self.Sn = sn
- self.Size = size
-
- msg = ""
- for i in range(0, size-len(str(self.Sn))) :
- msg += ' '
-
- self.Data = str(self.Sn) + msg
-
- def InitWithMsg(self, msg) :
- self.Sn = msg.strip()
- self.Size = len(msg) - len(self.Sn)
- self.Data = msg
-
- def GetData(self) :
- return self.Data
-
-
-def Log(s) :
- logging.error(s)
-
-
-gSndSn = 0
-def SndPkts() :
- global gSndSn,gSndDelay,gSndPktCnt
- data = Data()
- data.Init(gSndSn, gPktSize)
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- s.bind(('', 2766))
- s.sendto(data.GetData(), (gSndDst, gPort))
- Log('sended sn {0}'.format(data.Sn))
- gSndSn += 1
- if gSndSn < gSndPktCnt :
- Timer(gSndDelay, SndPkts, ()).start()
- s.close()
-
-def Client() :
- global gSndDelay, gSndSn, gSndPktCnt
- gSndSn = 0
- print gSndDelay
- Timer(gSndDelay, SndPkts, ()).start()
- Log('send data size {0}'.format(gPktSize))
- while True :
- print gSndSn, gSndPktCnt
- if gSndSn >= gSndPktCnt :
- break
- time.sleep(1)
-
-def Server() :
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- s.bind(('',gPort))
- Log('waiting on port {0}'.format(gPort))
- while True :
- (msg, (addr, port)) = s.recvfrom(1024)
- data = Data()
- data.InitWithMsg(msg)
- print "dsfasdfads"
- Log('received sn {0}'.format(data.Sn))
-
-def main() :
- mode = 'cli'
- try :
- mode = sys.argv[1]
- except :
- print "svr or cli ?"
- sys.exit()
- global gSndDst, gPort, gSndPktSize, gSndPktCnt, gSndHz, gSndDelay
-
- if mode == 'cli' :
- if len(sys.argv) != 7 :
- print "{0} <cli> <SndDst> <Port> <SndPktSize> <SndPktCnt> <SndHz>".format(sys.argv[0])
- sys.exit()
-
- gSndDst = sys.argv[2]
- gPort = int(sys.argv[3])
- gSndPktSize = int(sys.argv[4])
- gSndPktCnt = int(sys.argv[5])
- gSndHz = int(sys.argv[6])
- gSndDelay = float(1.0 / (gSndHz+gSndHz*0.01))
- Client()
- elif mode == 'svr' :
- if len(sys.argv) != 3 :
- print "{0} <svr> <Port>".format(sys.argv[0])
- sys.exit()
- gPort = int(sys.argv[2])
- Server()
- else :
- pass
-
-if __name__ == "__main__" :
- main()
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# --------------------------------------------------------------------------
-# File Name: analyzeCSDN.py
-# Author: Zhao Yanbai
-# Fri Jan 13 12:17:10 2012
-# Description: 将网络上泄露的CSDN网站的账号密码及电子邮件信息提取出来并构造
-# 成插入数据库的SQL语句
-# --------------------------------------------------------------------------
-
-import re
-
-try :
- inf = open("./www.csdn.net.sql", "r")
- ouf = open("./csdn.sql", "w")
-except IOError as ioerr :
- print "Error: ", ioerr
- exit();
-
-# 将每10000条记录生成成一条SQL
-# 如果一条SQL中含的记录太多,则在MYSQL中执行会超时
-itemperline = 10000
-
-i = 0
-while True:
-
- line = inf.readline()
-
- if(len(line) == 0) :
- ouf.write(";")
- break;
-
- # 去掉行尾的 \r\n
- line = line[:-2]
-
- # 将gb2312编码转换成utf-8编码
- try :
- line = unicode(line, "gbk").encode("utf-8")
- except UnicodeDecodeError as err :
- print "Error Msg: ", err
- print "Error Line: ", line
- continue
-
- # 构造的SQL语句针对客串形式的参数需要用至"'"
- # 所以需要将密码中的"'"转换成"\'",涉及到转义的问题,所以为"\\'"
- # 如果\是最后一个字符也会造成SQL语句构造错误
- line = line.replace("\\", "\\\\")
- line = line.replace("'", "\\'")
-
- # 提取用户名、密码、Email
- D = re.findall(r'(.*) # (.*) # (.*)', line)
-
- # 构造SQL语句
- if(i % itemperline == 0) :
- ouf.write("INSERT INTO csdn VALUES")
- else :
- ouf.write(",")
- ouf.write("(NULL,'" + D[0][0] +"','" + D[0][1] +"','" + D[0][2] + "')")
- if((i+1) % itemperline == 0) :
- ouf.write(";")
-
- i += 1
-
-inf.close();
-ouf.close();
+++ /dev/null
-#!/bin/bash
-# 哄baby睡觉的强力程序
-# 所要做的就是把光驱用绳子连在摇篮上
-# 网上视频中抄的
-while [ 1 = 1 ]
-do
- eject
-
- eject -t
-done
-
+++ /dev/null
-#!/usr/bin/perl
-
-use strict;
-
-my $file = $ARGV[0];
-my $time = localtime();
-my $del;
-
-if(!$file){
- die "Please add your perl file name...\n";
-}
-
-if (-e $file){
- do{
- print "File $file already exists, delete...[y/N]";
- chomp ($del = <STDIN>);
- }while($del ne "y" && $del ne "N");
-
- if($del eq "y"){
- unlink($file) || die "Can not delete file: $file\n";
- }
- else{
- exit;
- }
-}
-
-open FILE, ">", "$file";
-print FILE "#!/usr/bin/perl\n";
-print FILE "# " . "-"x72 . "\n";
-print FILE "# File Name:\t$file\n";
-print FILE "# Author:\tZhao Yanbai\n";
-print FILE "# \t$time\n";
-print FILE "# Description:\tnone\n";
-print FILE "# " . "-"x72 . "\n";
-print FILE "use strict;\n\n";
-close FILE;
-chmod 0755,$file;
+++ /dev/null
-/*
- *--------------------------------------------------------------------------
- * File Name: cpy.c
- *
- * Author: Zhao Yanbai [zhaoyanbai@126.com]
- * Wed Jun 30 11:22:16 2010
- *
- * Description: none
- *
- *--------------------------------------------------------------------------
- */
-
-#include <stdio.h>
-#include <time.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-int main(int argc, char *argv[])
-{
- int fd;
- time_t now;
- char timestr[256];
- char cmd[] = "#!/usr/bin/env python\n";
- char charset[] = "# -*- coding: utf-8 -*-\n";
- char line[] = "# -------------------------------------"
- "-------------------------------------\n";
- char file[] = "# File Name:\t";
- char author[] = "\n# Author:\tZhao Yanbai\n#\t\t";
- char desc[] = "# Description:\tnone\n";
-
- if(argc != 2)
- {
- printf("usage: %s <file.py>\n", argv[0]);
- exit(1);
- }
-
- now = time(NULL);
- strcpy(timestr, ctime(&now));
-
- fd = open(argv[1], O_CREAT | O_WRONLY,
- S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
- write(fd, cmd, strlen(cmd));
- write(fd, charset, strlen(charset));
- write(fd, line, strlen(line));
- write(fd, file, strlen(file));
- write(fd, argv[1], strlen(argv[1]));
- write(fd, author, strlen(author));
- write(fd, timestr, strlen(timestr));
- write(fd, desc, strlen(desc));
- write(fd, line, strlen(line));
-
- close(fd);
- return 0;
-}
+++ /dev/null
-// By Zhao Yanbai
-// 2008.12.10
-// Version 1.0
-#include<cstdio>
-#include<ctime>
-#include<cstring>
-#include<iostream>
-#include<string>
-using namespace std;
-void usage()
-{
- printf("usage...\n");
-}
-
-int main(int argc, char *argv[])
-{
- FILE *fp;
- time_t now = time(NULL);
- const char *sfile = argv[1];
- int len = strlen(sfile);
- string project;
- string hstr;
-
- if(argc != 2)
- {
- usage();
- return 1;
- }
-
- if((fp = fopen(argv[1],"w+")) == NULL)
- {
- printf("cannot create file\n");
- return 1;
- }
- fprintf(fp,"/*\n");
- fprintf(fp," *--------------------------------------------------------------------------\n");
- fprintf(fp," * File Name:\t%s\n",argv[1]);
- fprintf(fp," * \n");
- fprintf(fp," * Author:\tZhao Yanbai [zhaoyanbai@126.com]\n");
- fprintf(fp," * \t\t\t%s",ctime(&now));
- fprintf(fp," * \n");
- fprintf(fp," * Description:\tnone\n");
- fprintf(fp," * \n");
- fprintf(fp," *--------------------------------------------------------------------------\n");
- fprintf(fp," */\n\n");
-
- if(argv[1][len-1] == 'h' && argv[1][len-2] == '.')
- {
-
- cout<<"Project Name:";
- cin>>project;
-
- hstr += project;
- hstr += "_";
- hstr += argv[1];
-
- for(int i=0; i<hstr.length(); i++)
- {
- if(hstr[i] == '.')
- hstr[i] = '_';
- else
- hstr[i] = toupper(hstr[i]);
- }
- hstr += "_";
-
- fprintf(fp,"#ifndef\t%s\n",hstr.c_str());
- fprintf(fp,"#define\t%s\n\n\n\n",hstr.c_str());
- fprintf(fp,"#endif //%s",hstr.c_str());
- }
-
- fclose(fp);
- return 0;
-}
+++ /dev/null
-// By Zhao Yanbai
-// 2008.12.10
-// Version 1.0
-#include<cstdio>
-#include<ctime>
-#include<cstring>
-#include<iostream>
-#include<string>
-using namespace std;
-void usage()
-{
- printf("usage...\n");
-}
-
-int main(int argc, char *argv[])
-{
- FILE *fp;
- time_t now = time(NULL);
- int len = strlen(argv[1]);
- string project;
- string hstr;
-
- if(argc != 2)
- {
- usage();
- return 1;
- }
-
- if((fp = fopen(argv[1],"w+")) == NULL)
- {
- printf("cannot create file\n");
- return 1;
- }
- fprintf(fp,"/*\n");
- fprintf(fp," *--------------------------------------------------------------------------\n");
- fprintf(fp," * File Name:\t%s\n",argv[1]);
- fprintf(fp," * \n");
- fprintf(fp," * Create Date: %s",ctime(&now));
- fprintf(fp," * \n");
- fprintf(fp," * Author:\tZhao Yanbai [zhaoyanbai@126.com]\n");
- fprintf(fp," * \t\tInformation Security Research Center Of\n");
- fprintf(fp," * \t\tHarbin Engineering University\n");
- fprintf(fp," * \n");
- fprintf(fp," * Description:\tnone\n");
- fprintf(fp," * \n");
- fprintf(fp," *--------------------------------------------------------------------------\n");
- fprintf(fp," */\n\n");
-
- if(argv[1][len-1] == 'h' && argv[1][len-2] == '.')
- {
-
- cout<<"Project Name:";
- cin>>project;
-
- hstr += project;
- hstr += "_";
- hstr += argv[1];
-
- for(int i=0; i<hstr.length(); i++)
- {
- if(hstr[i] == '.')
- hstr[i] = '_';
- else
- hstr[i] = toupper(hstr[i]);
- }
- hstr += "_";
-
- fprintf(fp,"#ifndef\t%s\n",hstr.c_str());
- fprintf(fp,"#define\t%s\n\n\n\n",hstr.c_str());
- fprintf(fp,"#endif //%s",hstr.c_str());
- }
-
- fclose(fp);
- return 0;
-}
+++ /dev/null
-#!/usr/bin/perl -w
-# 将一个文件夹下的UTF-8编码的文件转换成gb2312
-use Encode;
-use Encode::CN;
-use Encode::Detect::Detector;
-$dirname = $ARGV[0];
-if(!$dirname)
-{
- print "Please add your Directory path\n";
- exit;
-}
-
-opendir ( DIR, $dirname) || die "Error in opening dir $dirname\n";
-while( ($filename = readdir(DIR))){
- if($filename eq "." || $filename eq ".."){
- next;
- }
- $filename = $dirname . "/" . $filename;
- open INF, "<$filename";
- $line = "";
- while(<INF>){
- $line = $line . $_;
- }
- close INF;
-
- print "Processing... $filename\n" unless (detect($line) =~ /gb/);
- $line=encode("gbk",decode("utf-8",$line)) unless (detect($line) =~ /gb/);
- open OUTF, ">$filename";
- print OUTF $line;
- close OUTF;
-
-
- open INF, "<$filename";
- $line = "";
- while(<INF>){
- $line = $line . $_;
- }
- close INF;
- unlink($filename) unless (detect($line) =~ /gb/);
-}
-closedir(DIR);
+++ /dev/null
-[EMAIL]
-MAILTO = xxx@xx.com
-MAILHOST= smtp.xx.com
-MAILUSER= xxx
-USERNICK= xx
-MAILPASS= *****
-MAILPOSTFIX= xx.com
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# ------------------------------------------------------------------------
-# File Name: GetWanIP.py
-# Author: Zhao Yanbai
-# Thu Oct 30 04:34:37 2014
-# Description: none
-# ------------------------------------------------------------------------
-import os
-import re,urllib2
-import smtplib
-import ConfigParser
-import config
-from email.mime.text import MIMEText
-from utils import *
-
-'''
- CONFIG FILE SAMPLE
-[EMAIL]
-MAILTO = xxx@xx.com
-MAILHOST= smtp.xx.com
-MAILUSER= xxxxx
-USERNICK= xxx
-MAILPASS= *****
-MAILPOSTFIX= xx.com
-'''
-'''
- CONTAB
-* * * * * root cd /xxx/xxx/xxx/ && python GetWanIP.py
-'''
-
-TMP_FILE_PATH = '/tmp/GetWanIP.txt'
-log = CreateLogger(config.ACE_GLOBAL_LOG_PATH)
-
-mailto_list=[]
-mail_host="" #设置服务器
-mail_user="" #用户名
-user_nick=""
-mail_pass="" #口令
-mail_postfix="" #发件箱的后缀
-
-class GetWanIP:
- def GetIP(self):
- try:
- log.info('Try ip.qq.com')
- WanIP = self.Visit('http://ip.qq.com')
- except:
- s = 'Failed to Get WanIP!!!'
- WanIP = s
- log.error(s)
- return WanIP
-
- def Visit(self,url):
- opener = urllib2.urlopen(url)
- if url == opener.geturl():
- str = opener.read()
- return re.search('\d+\.\d+\.\d+\.\d+',str).group(0)
-
-
-def send_mail(to_list,sub,content): #to_list:收件人;sub:主题;content:邮件内容
- me=user_nick+"<"+mail_user+"@"+mail_postfix+">" #这里的hello可以任意设置,收到信后,将按照设置显示
- msg = MIMEText(content,_subtype='html',_charset='gb2312') #创建一个实例,这里设置为html格式邮件
- msg['Subject'] = sub #设置主题
- msg['From'] = me
- msg['To'] = ";".join(to_list)
- try:
- s = smtplib.SMTP()
- s.connect(mail_host) #连接smtp服务器
- s.login(mail_user,mail_pass) #登陆服务器
- s.sendmail(me, to_list, msg.as_string()) #发送邮件
- s.close()
- return True
- except Exception, e:
- log.error(str(e))
- return False
-if __name__ == '__main__':
- try :
- fd = open(TMP_FILE_PATH)
- OldWanIP = fd.readline().strip()
- fd.close()
- except :
- OldWanIP = '0.0.0.0'
-
- getWanIP = GetWanIP()
- WanIP = getWanIP.GetIP()
-
- cnfp = ConfigParser.ConfigParser()
- cnfp.read(config.ACE_GLOBAL_CONF_PATH)
- mailto_list.append(cnfp.get('EMAIL', 'MAILTO'))
- mail_host = cnfp.get('EMAIL', 'MAILHOST')
- mail_user = cnfp.get('EMAIL', 'MAILUSER')
- user_nick = cnfp.get('EMAIL', 'USERNICK')
- mail_pass = cnfp.get('EMAIL', 'MAILPASS')
- mail_postfix = cnfp.get('EMAIL', 'MAILPOSTFIX')
-
- if OldWanIP != WanIP :
- s = 'WanIP has Changed From ' + OldWanIP + ' To ' + WanIP
- log.info(s)
- if send_mail(mailto_list,u'外网IP有变动', s):
- log.info('发送成功')
- fd = open(TMP_FILE_PATH, 'w+')
- fd.write(WanIP+'\n')
- fd.close()
- else:
- log.error('发送失败')
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# ------------------------------------------------------------------------
-# File Name: Sensors.py
-# Author: Zhao Yanbai
-# Thu Oct 30 14:46:58 2014
-# Description: none
-# ------------------------------------------------------------------------
-
-import time
-import serial
-import os
-import commands
-import config
-from utils import *
-
-log = CreateLogger(config.ACE_GLOBAL_LOG_PATH)
-
-s = serial.Serial('/dev/ttyACM0', 9600)
-
-ApiKey = 'c2ac9bff44b29c8f3edca022ed621aa9'
-class Sensor :
- def __init__(self, Name, url) :
- self.Name = Name
- self.Url = url
- self.LastTs = 0
- self.Value = 0
-
-Map = { }
-
-SensorList = [Sensor('Light', 'http://api.yeelink.net/v1.0/device/15328/sensor/26264/datapoints'),
- Sensor('Temperature', 'http://api.yeelink.net/v1.0/device/15328/sensor/26256/datapoints')]
-
-for x in SensorList :
- Map[x.Name] = x
-
-while True :
- line = s.readline().strip()
-
- if line[0] != '>' :
- continue
-
- log.info(line)
-
- (name, value) = line[1:].strip().split(': ')
- if Map.get(name, None) == None :
- continue
-
- if int(time.time()) - Map[name].LastTs < 10 :
- continue
-
- log.info('Prepare to Report')
-
- Map[name].LastTs = int(time.time())
- Map[name].Value = float(value)
-
- json = '{"value":%f}' % Map[name].Value
- fd = open('datafile.txt', 'w+')
- fd.write(json + '\n')
- fd.close()
-
- cmd = 'curl --request POST --data-binary @datafile.txt --header "U-ApiKey: '+ApiKey+'" ' + Map[name].Url
- output = commands.getoutput(cmd)
- log.info(output)
-
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# ------------------------------------------------------------------------
-# File Name: __init__.py
-# Author: Zhao Yanbai
-# Thu Oct 30 06:21:42 2014
-# Description: none
-# ------------------------------------------------------------------------
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# ------------------------------------------------------------------------
-# File Name: config.py
-# Author: Zhao Yanbai
-# Thu Oct 30 06:37:52 2014
-# Description: none
-# ------------------------------------------------------------------------
-
-
-ACE_GLOBAL_CONF_PATH = '/etc/AceGlobal.conf'
-ACE_GLOBAL_LOG_PATH = '/var/log/AceGlobal.log'
+++ /dev/null
-pyinotify
-https://github.com/seb-m/pyinotify/archive/0.9.4.tar.gz
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# ------------------------------------------------------------------------
-# File Name: utils.py
-# Author: Zhao Yanbai
-# Thu Oct 30 06:33:24 2014
-# Description: none
-# ------------------------------------------------------------------------
-
-import logging
-
-def CreateLogger(logpath, level=logging.DEBUG) :
- logger = logging.getLogger(logpath)
- fmtr = logging.Formatter('%(levelname)s\t%(asctime)s: %(message)s')
-
- fileHdlr = logging.FileHandler(logpath)
- fileHdlr.setFormatter(fmtr)
- fileHdlr.setLevel(level)
-
- streamHdlr = logging.StreamHandler()
- streamHdlr.setFormatter(fmtr)
- streamHdlr.setLevel(level)
-
- logger.addHandler(fileHdlr)
- logger.addHandler(streamHdlr)
- logger.setLevel(level)
-
- return logger
-