Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b3b2c38

Browse files
committed
Minor code refactoring
1 parent 72a9013 commit b3b2c38

5 files changed

Lines changed: 21 additions & 20 deletions

File tree

lib/core/common.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -949,23 +949,6 @@ def getFileType(filePath):
949949
else:
950950
return "binary"
951951

952-
def pollProcess(process):
953-
while True:
954-
dataToStdout(".")
955-
time.sleep(1)
956-
957-
returncode = process.poll()
958-
959-
if returncode is not None:
960-
if returncode == 0:
961-
dataToStdout(" done\n")
962-
elif returncode < 0:
963-
dataToStdout(" process terminated by signal %d\n" % returncode)
964-
elif returncode > 0:
965-
dataToStdout(" quit unexpectedly with return code %d\n" % returncode)
966-
967-
break
968-
969952
def getCharset(charsetType=None):
970953
asciiTbl = []
971954

lib/core/subprocessng.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import sys
1313
import time
1414

15+
from lib.core.common import dataToStdout
1516
from lib.core.settings import IS_WIN
1617

1718
if not IS_WIN:
@@ -71,3 +72,20 @@ def setNonBlocking(fd):
7172
flags = fcntl.fcntl(fd, FCNTL.F_GETFL)
7273
flags = flags | os.O_NONBLOCK
7374
fcntl.fcntl(fd, FCNTL.F_SETFL, flags)
75+
76+
def pollProcess(process):
77+
while True:
78+
dataToStdout(".")
79+
time.sleep(1)
80+
81+
returncode = process.poll()
82+
83+
if returncode is not None:
84+
if returncode == 0:
85+
dataToStdout(" done\n")
86+
elif returncode < 0:
87+
dataToStdout(" process terminated by signal %d\n" % returncode)
88+
elif returncode > 0:
89+
dataToStdout(" quit unexpectedly with return code %d\n" % returncode)
90+
91+
break

lib/core/update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626

2727
from lib.core.common import dataToStdout
2828
from lib.core.common import getUnicode
29-
from lib.core.common import pollProcess
3029
from lib.core.common import readInput
3130
from lib.core.data import conf
3231
from lib.core.data import logger
3332
from lib.core.data import paths
3433
from lib.core.exception import sqlmapConnectionException
3534
from lib.core.exception import sqlmapFilePathException
3635
from lib.core.settings import MSSQL_VERSIONS_URL
36+
from lib.core.subprocessng import pollProcess
3737
from lib.request.connect import Connect as Request
3838

3939
def __updateMSSQLXML():

lib/takeover/metasploit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from lib.core.common import getUnicode
2525
from lib.core.common import normalizePath
2626
from lib.core.common import ntToPosixSlashes
27-
from lib.core.common import pollProcess
2827
from lib.core.common import randomRange
2928
from lib.core.common import randomStr
3029
from lib.core.common import readInput
@@ -35,6 +34,7 @@
3534
from lib.core.exception import sqlmapFilePathException
3635
from lib.core.subprocessng import blockingReadFromFD
3736
from lib.core.subprocessng import blockingWriteToFD
37+
from lib.core.subprocessng import pollProcess
3838
from lib.core.subprocessng import setNonBlocking
3939
from lib.request.connect import Connect as Request
4040
from lib.takeover.upx import upx

lib/takeover/upx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
from lib.core.common import dataToStdout
1919
from lib.core.common import decloakToMkstemp
20-
from lib.core.common import pollProcess
2120
from lib.core.data import logger
2221
from lib.core.data import paths
2322
from lib.core.settings import PLATFORM
23+
from lib.core.subprocessng import pollProcess
2424

2525
class UPX:
2626
"""

0 commit comments

Comments
 (0)