Minor code refactoring

This commit is contained in:
Bernardo Damele 2010-10-29 10:51:09 +00:00
parent 72a901347d
commit b3b2c3864a
5 changed files with 21 additions and 20 deletions

View File

@ -949,23 +949,6 @@ def getFileType(filePath):
else: else:
return "binary" return "binary"
def pollProcess(process):
while True:
dataToStdout(".")
time.sleep(1)
returncode = process.poll()
if returncode is not None:
if returncode == 0:
dataToStdout(" done\n")
elif returncode < 0:
dataToStdout(" process terminated by signal %d\n" % returncode)
elif returncode > 0:
dataToStdout(" quit unexpectedly with return code %d\n" % returncode)
break
def getCharset(charsetType=None): def getCharset(charsetType=None):
asciiTbl = [] asciiTbl = []

View File

@ -12,6 +12,7 @@ import os
import sys import sys
import time import time
from lib.core.common import dataToStdout
from lib.core.settings import IS_WIN from lib.core.settings import IS_WIN
if not IS_WIN: if not IS_WIN:
@ -71,3 +72,20 @@ def setNonBlocking(fd):
flags = fcntl.fcntl(fd, FCNTL.F_GETFL) flags = fcntl.fcntl(fd, FCNTL.F_GETFL)
flags = flags | os.O_NONBLOCK flags = flags | os.O_NONBLOCK
fcntl.fcntl(fd, FCNTL.F_SETFL, flags) fcntl.fcntl(fd, FCNTL.F_SETFL, flags)
def pollProcess(process):
while True:
dataToStdout(".")
time.sleep(1)
returncode = process.poll()
if returncode is not None:
if returncode == 0:
dataToStdout(" done\n")
elif returncode < 0:
dataToStdout(" process terminated by signal %d\n" % returncode)
elif returncode > 0:
dataToStdout(" quit unexpectedly with return code %d\n" % returncode)
break

View File

@ -26,7 +26,6 @@ from subprocess import Popen as execute
from lib.core.common import dataToStdout from lib.core.common import dataToStdout
from lib.core.common import getUnicode from lib.core.common import getUnicode
from lib.core.common import pollProcess
from lib.core.common import readInput from lib.core.common import readInput
from lib.core.data import conf from lib.core.data import conf
from lib.core.data import logger from lib.core.data import logger
@ -34,6 +33,7 @@ from lib.core.data import paths
from lib.core.exception import sqlmapConnectionException from lib.core.exception import sqlmapConnectionException
from lib.core.exception import sqlmapFilePathException from lib.core.exception import sqlmapFilePathException
from lib.core.settings import MSSQL_VERSIONS_URL from lib.core.settings import MSSQL_VERSIONS_URL
from lib.core.subprocessng import pollProcess
from lib.request.connect import Connect as Request from lib.request.connect import Connect as Request
def __updateMSSQLXML(): def __updateMSSQLXML():

View File

@ -24,7 +24,6 @@ from lib.core.common import getRemoteIP
from lib.core.common import getUnicode from lib.core.common import getUnicode
from lib.core.common import normalizePath from lib.core.common import normalizePath
from lib.core.common import ntToPosixSlashes from lib.core.common import ntToPosixSlashes
from lib.core.common import pollProcess
from lib.core.common import randomRange from lib.core.common import randomRange
from lib.core.common import randomStr from lib.core.common import randomStr
from lib.core.common import readInput from lib.core.common import readInput
@ -35,6 +34,7 @@ from lib.core.exception import sqlmapDataException
from lib.core.exception import sqlmapFilePathException from lib.core.exception import sqlmapFilePathException
from lib.core.subprocessng import blockingReadFromFD from lib.core.subprocessng import blockingReadFromFD
from lib.core.subprocessng import blockingWriteToFD from lib.core.subprocessng import blockingWriteToFD
from lib.core.subprocessng import pollProcess
from lib.core.subprocessng import setNonBlocking from lib.core.subprocessng import setNonBlocking
from lib.request.connect import Connect as Request from lib.request.connect import Connect as Request
from lib.takeover.upx import upx from lib.takeover.upx import upx

View File

@ -17,10 +17,10 @@ from subprocess import Popen as execute
from lib.core.common import dataToStdout from lib.core.common import dataToStdout
from lib.core.common import decloakToMkstemp from lib.core.common import decloakToMkstemp
from lib.core.common import pollProcess
from lib.core.data import logger from lib.core.data import logger
from lib.core.data import paths from lib.core.data import paths
from lib.core.settings import PLATFORM from lib.core.settings import PLATFORM
from lib.core.subprocessng import pollProcess
class UPX: class UPX:
""" """