-
<PYTHON>파싱결과 비교(contents) --> 파일 저장Flower in my dev/Python 2015. 5. 29. 09:57
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 import os nFile = 'flower_new.txt' oFile = 'flower_old.txt' nRead = open(nFile, 'r') oRead = open(oFile, 'r') nList = nRead.readlines() oList = oRead.readlines() fResult = open('flower_result.txt', 'w') cnt = 0 if len(nList) == len(oList): fResult.write("[Same Length]" + '\n') for n in nList: o = oLis..
-
<PYTHON>디렉토리 검색 및 xml 파싱 --> 파일 저장Flower in my dev/Python 2015. 5. 29. 09:54
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 import os, sys from bs4 import BeautifulSoup saveList = [] cnt01 = 0 cnt02 = 0 newPath = '경로/new_device' oldPath = '경로/old_device' nFile = 'flower_new' oFile = 'flower_old' nList = os.listdir(newPath) oList = os.listdir(oldPath) nFull = os.path.join(newPath, nFile) oFu..
-
-
-
<PYTHON> twisted log 사용Flower in my dev/Python 2015. 5. 27. 13:39
1 2 3 4 5 6 7 8 9 10 #---Flower Adding--- from twisted.python import log as flower from twisted.python import logfile fLog = logfile.LogFile("/log/bin/flower.log", "/log/bin/", rotateLength=0) flower.startLogging(fLog) fLog.rotate() #------------------- flower.msg("[function]====== Sequence Number [000]") flower.msg(">>value : ", value) Colored by Color Scripter cs rotateLength : 로그파일 크기(byte) r..
-
<PYTHON>특정기간 지난 파일 삭제Flower in my dev/Python 2015. 5. 22. 09:38
# 파일 이름이 날짜시간이어야 함. # 경로는 IP로 단순히 정의했음. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 #-*- coding: utf-8 -*- import os, re from datetime import date, timedelta filePath = '경로/rawlog' class LogRemover: def __init__(self, dPath = filePath, days = 7): self.defaultPath = dPath self.duDays = days def getFileList(self): ipCheck = r..
-
-
<PYTHON>일반 정규식 예Flower in my dev/Python 2015. 5. 18. 20:38
1 2 3 4 5 6 7 8 9 RE_ANYTHING = r".*" RE_INTEGER = r"\d+" RE_EPOCHTIME = r"\d+(?:\.\d*)?" RE_SYSLOGDATE = r"[A-Z][a-z]{2} [ 0-3]?\d \d{2}:\d{2}:\d{2}" # Jan 5 09:38:18 RE_URL = r"http[s]?://[^ \"\'*]+" RE_MAC = r"[0-9a-fA-F]{2}[:\-\.]?(?:[0-9a-fA-F]{2}[:\-\.]?){4}[0-9a-fA-F]{2}" RE_IP = r"(?