text
stringlengths
0
828
## But do not wait till netstat finish, start displaying output immediately ##
while True:
out = proc.stderr.read(1)
if out == '' and proc.poll() != None:
break
if out != '':
sys.stdout.write(out)
sys.stdout.flush()
return proc.returncode"
3759,"def cleanUpPparse(outputpath, rawfilename, mgf=False):
""""""Delete temporary files generated by pparse, including the filetypes
"".csv"", "".ms1"", "".ms2"", "".xtract"", the files ""pParsePlusLog.txt"" and
""pParse.para"" and optionally also the "".mgf"" file generated by pParse.
.. warning:
When the parameter ""mgf"" is set to ""True"" all files ending with "".mgf""
and containing the specified ""filename"" are deleted. This could
potentially also affect MGF files not generated by pParse.
:param outputpath: path to the output directory of pParse
:param rawfilename: filename of the thermo "".raw"" file
:param mgf: bool, if True the "".mgf"" file generated by pParse is also
removed
""""""
extensions = ['csv', 'ms1', 'ms2', 'xtract']
filename, fileext = os.path.splitext(os.path.basename(rawfilename))
additionalFiles = [aux.joinpath(outputpath, 'pParsePlusLog.txt'),
aux.joinpath(outputpath, filename+'.pparse.para'),
]
for ext in extensions:
filepath = aux.joinpath(outputpath, '.'.join([filename, ext]))
if os.path.isfile(filepath):
print('Removing file: ', filepath)
os.remove(filepath)
for filepath in additionalFiles:
if os.path.isfile(filepath):
print('Removing file: ', filepath)
os.remove(filepath)
if mgf:
for _filename in os.listdir(outputpath):
_basename, _fileext = os.path.splitext(_filename)
if _fileext.lower() != '.mgf':
continue
if _basename.find(basename) != -1 and _basename != basename:
filepath = aux.joinpath(outputpath, _filename)
print('Removing file: ', filepath)
os.remove(filepath)"
3760,"def launch_server(message_handler, options):
""""""
Launch a message server
:param handler_function: The handler function to execute for each message
:param options: Application options for TCP, etc.
""""""
logger = logging.getLogger(__name__)
if (options.debug):
logger.setLevel(logging.DEBUG)
if not options.monitor_port:
logger.warning(
""Monitoring not enabled. No monitor-port option defined."")
else:
threading.Thread(target=launch_monitor_server, args=(options.host, options.monitor_port, logger)).start()
# Create the server, binding to specified host on configured port
logger.info(
'Starting server on host %s port %d Python version %s.%s.%s' % ((options.host, options.port) + sys.version_info[:3]))
server = ThreadedTCPServer((options.host, options.port),
StreamHandler.create_handler(message_handler,
options.buffer_size,
logger))
# Activate the server; this will keep running until you
# interrupt the program with Ctrl-C
try:
server.serve_forever()
except KeyboardInterrupt:
logger.info(""Ctrl-C, exiting..."")
os._exit(142)"
3761,"def launch_monitor_server(host, port, logger):
""""""
Launch a monitor server
:param port: the monitor port
:param logger: the logger
""""""
logger.info('Starting monitor server on host %s port %d' % (host, port))
server = ThreadedTCPServer((host, port), MonitorHandler)
server.serve_forever()"
3762,"def create_handler(cls, message_handler, buffer_size, logger):
""""""
Class variables used here since the framework creates an instance for each connection
:param message_handler: the MessageHandler used to process each message.
:param buffer_size: the TCP buffer size.
:param logger: the global logger.
:return: this class.
""""""