本文整理汇总了Python中java.io.PrintWriter类的典型用法代码示例。如果您正苦于以下问题:Python PrintWriter类的具体用法?Python PrintWriter怎么用?Python PrintWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PrintWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ig_dump_dot
def ig_dump_dot(dmuid,filename):
igm = project.getIGM()
uid = DMUID.parse(dmuid)
module = igm.findModule(Toplevel(uid, None))
if module == None:
printf('DM %s not found', dmuid)
else:
printf('Dumping %s...', module)
dot = IG2DOT(module);
dot.blacklistField("fImportedLibs");
dot.blacklistField("fImportedPackages");
dot.blacklistField("fZPrjID");
dot.blacklistField("fSFDBID");
dot.blacklistField("fLine");
dot.blacklistField("fCol");
dot.blacklistField("fScore");
dot.blacklistField("fFailed");
dot.blacklistField("fReject");
dot.blacklistField("fInertial");
dot.blacklistField("fDelay");
out = PrintWriter(BufferedWriter(FileWriter(filename)));
dot.convert(out);
out.close()
printf("python: wrote dot file to %s", filename)
示例2: rtl_dump_svg
def rtl_dump_svg(dmuid,filename):
rtlmanager = project.getRTLM()
uid = DMUID.parse(dmuid)
rtlm = rtlmanager.findModule(Toplevel(uid, None))
if rtlm == None:
printf('RTLM %s not found', dmuid)
else:
printf('Dumping %s...', rtlm)
out = PrintWriter(BufferedWriter(FileWriter(filename)))
gc = VGGCSVG(out)
contentProvider = RTLVisualGraphContentProvider(rtlm)
labelProvider = RTLVisualGraphLabelProvider(rtlm)
selectionProvider = RTLVisualGraphSelectionProvider()
layout = VGLayout(contentProvider, labelProvider, gc)
layout.paint(selectionProvider);
out.close()
printf("python: wrote svg file to %s", filename)
示例3: testCSVPipe
def testCSVPipe(self):
"""testing the CSV pipe"""
from java.io import PrintWriter, FileWriter
from com.ziclix.python.sql.pipe import Pipe
from com.ziclix.python.sql.pipe.db import DBSource
from com.ziclix.python.sql.pipe.csv import CSVSink
try:
src = self.connect()
fn = tempfile.mktemp(suffix="csv")
writer = PrintWriter(FileWriter(fn))
csvSink = CSVSink(writer)
c = self.cursor()
try:
c.execute("insert into zxtesting (id, name, state) values (?, ?, ?)", [(1000, 'this,has,a,comma', 'and a " quote')])
c.execute("insert into zxtesting (id, name, state) values (?, ?, ?)", [(1001, 'this,has,a,comma and a "', 'and a " quote')])
# ORACLE has a problem calling stmt.setObject(index, null)
c.execute("insert into zxtesting (id, name, state) values (?, ?, ?)", [(1010, '"this,has,a,comma"', None)], {2:zxJDBC.VARCHAR})
self.db.commit()
finally:
self.db.rollback()
c.close()
dbSource = DBSource(src, c.datahandler.__class__, "zxtesting", None, None, None)
cnt = Pipe().pipe(dbSource, csvSink) - 1 # ignore the header row
finally:
writer.close()
src.close()
os.remove(fn)
示例4: dm_dump_dot
def dm_dump_dot(dmuid,filename):
dmm = project.getDUM()
uid = DMUID.parse(dmuid)
dm = dmm.getDM(uid)
if dm == None:
printf('DM %s not found', dmuid)
else:
printf('Dumping %s...', dm)
dot = AST2DOT(dm, project.getZDB())
dot.blacklistField("fParent")
# dot.blacklistField("fSource")
# dot.blacklistField("fStartCol")
# dot.blacklistField("fStartLine")
dot.blacklistField("fEndCol")
dot.blacklistField("fEndLine")
dot.blacklistField("fDeclarationMap")
out = PrintWriter(BufferedWriter(FileWriter(filename)));
dot.convert(out);
out.close()
printf("python: wrote dot file to %s", filename)
示例5: register_script
def register_script(self):
"""
Registers a pig scripts with its variables substituted.
raises: IOException If a temp file containing the pig script could not be created.
raises: ParseException The pig script could not have all its variables substituted.
todo: Refactor this processes that result in calling this method. This method gets
called twice for a single assert as every method that needs the data assumes no one
else has called it (even methods that call other methods that call it (assertOutput()
calls get_alias() which both call this method).
"""
pigIStream = BufferedReader(StringReader(self.orig_pig_code))
pigOStream = StringWriter()
ps = ParameterSubstitutionPreprocessor(50) # Where does 50 come from?
ps.genSubstitutedFile(pigIStream, pigOStream, self.args, self.arg_files)
substitutedPig = pigOStream.toString()
f = File.createTempFile("tmp", "pigunit")
pw = PrintWriter(f)
pw.println(substitutedPig)
pw.close()
pigSubstitutedFile = f.getCanonicalPath()
self._temp_pig_script = pigSubstitutedFile
self.pig.registerScript(pigSubstitutedFile, self.alias_overrides)
示例6: BurpExtender
class BurpExtender(IBurpExtender, IScannerListener, IExtensionStateListener):
# init module settings and variables
# hoping to make this a GUI option (not sure how yet)
#
# implement IBurpExtender
#
def registerExtenderCallbacks(self, callbacks):
# keep a reference to our callbacks object
self._callbacks = callbacks
# set our extension name
callbacks.setExtensionName("Scanner Streamer [c22]")
# obtain our output stream
self._stdout = PrintWriter(callbacks.getStdout(), True)
# register ourselves as a Scanner listener
callbacks.registerScannerListener(self)
# register ourselves as an extension state listener
callbacks.registerExtensionStateListener(self)
# call initExtension routine
initExtension()
return
#
# implement IScannerListener
#
def newScanIssue(self, issue):
if domainInScope(self, issue):
# check if finding already displayed for this hostname
if newFinding(issue):
outputFinding(self, issue)
else:
# already displayed
if verbose:
self._stdout.println("[-] Finding already displayed (%s)" % issue.getIssueName())
return
#
# implement IExtensionStateListener
#
def extensionUnloaded(self):
self._stdout.println("\n[!] Scanner_Streamer.py extension was unloaded")
return
示例7: createInputFile
def createInputFile(self, fs, fileName, input_data):
if(fs.exists(Path(fileName))):
raise IOException("File " + fileName + " already exists on the minicluster")
stream = fs.create(Path(fileName))
pw = PrintWriter(OutputStreamWriter(stream, "UTF-8"))
for i in xrange(len(input_data)):
pw.println(input_data[i])
pw.close();
示例8: registerExtenderCallbacks
def registerExtenderCallbacks(self, callbacks):
callbacks.setExtensionName("Seccasts Tutorial - Jython")
stdout = PrintWriter(callbacks.getStdout(), True)
stdout.println("Hello from Seccasts!")
return
示例9: BurpExtender
class BurpExtender(IBurpExtender, IHttpRequestResponse, IHttpService, ITab):
def registerExtenderCallbacks(self, callbacks):
self.callbacks = callbacks
self.helpers = callbacks.getHelpers()
self.stdout = PrintWriter(callbacks.getStdout(), True)
self.stderr = PrintWriter(callbacks.getStderr(), True)
callbacks.setExtensionName('Save URL List')
self.panel = JPanel()
self.myLabel = JLabel('Save URL List as a Text File', JLabel.CENTER)
self.buttonFile = Button('Select File', actionPerformed=self.selectFile)
self.buttonSaveProxy = Button('Save All Proxy History', actionPerformed=self.saveProxy)
self.buttonSaveSiteTree = Button('Save All Target SiteTree ', actionPerformed=self.saveSiteTree)
self.buttonSaveProxyScope = Button('Save In-Scope Proxy History', actionPerformed=self.saveProxyScope)
self.buttonSaveSiteTreeScope = Button('Save In-Scope Target SiteTree', actionPerformed=self.saveSiteTreeScope)
self.panel.add(self.myLabel)
self.panel.add(self.buttonFile)
self.panel.add(self.buttonSaveProxy)
self.panel.add(self.buttonSaveSiteTree)
self.panel.add(self.buttonSaveProxyScope)
self.panel.add(self.buttonSaveSiteTreeScope)
callbacks.customizeUiComponent(self.panel)
callbacks.addSuiteTab(self)
def getTabCaption(self):
return 'URL List'
def getUiComponent(self):
return self.panel
def selectFile(self, event):
chooser = JFileChooser()
retVal = chooser.showSaveDialog(None)
self.saveFile = chooser.selectedFile.path
def saveProxy(self, event):
self.stdout.println('Writing Entire Proxy History URL List to File: ' + self.saveFile)
writer = open(self.saveFile, 'w')
proxyHistory = self.callbacks.getProxyHistory()
if proxyHistory:
for item in proxyHistory:
try:
request = item.getRequest()
if request:
service = item.getHttpService()
myURL = self.helpers.analyzeRequest(service, request).getUrl().toString()
writer.write(myURL + '\n')
except Exception, e:
self.stderr.println('Error Writing URL.')
continue
else:
示例10: registerExtenderCallbacks
def registerExtenderCallbacks(self, callbacks):
# set our extension name
callbacks.setExtensionName("G2 Determine Session Cookie")
callbacks.registerContextMenuFactory(DetermineCookieMenuItem(callbacks))
# obtain our output and error streams
stdout = PrintWriter(callbacks.getStdout(), True)
stderr = PrintWriter(callbacks.getStderr(), True)
# write a message to our output stream
stdout.println("G2 Determine Session Cookie - Successful Initialization")
示例11: Connection
class Connection(object):
def __init__(self, addr, port):
self.socket = Socket(addr, port)
self.in = BufferedReader(InputStreamReader(self.socket.getInputStream()))
self.out = PrintWriter(self.socket.getOutputStream(), True)
def sendMessage(self, msg):
self.out.println(str(msg))
response = self.in.readLine()
if response is None: # abort abort abort
exit(1)
decoded = Message.decode(response)
return decoded.msgData # empty string or hash
示例12: BurpExtender
class BurpExtender(IBurpExtender, IIntruderPayloadProcessor):
def registerExtenderCallbacks(self, callbacks):
self._callbacks = callbacks
self._helpers = callbacks.getHelpers()
# Register methods for error reporting
self.stdout = PrintWriter(callbacks.getStdout(), True)
self.stderr = PrintWriter(callbacks.getStderr(), True)
self.stdout.println("Module loaded successfully!")
callbacks.setExtensionName('Simple Burp Intruder Payload Processor')
callbacks.registerIntruderPayloadProcessor(self)
return
def getProcessorName():
return "Capitalize Payload Process"
def processPayload(currentPayload, originalPayload, baseValue):
try:
# Data will be outputted to Burp UI by default
self.stdout.println("currentPayload: %s" % currentPayload)
newPayload = capitalize(currentPayload)
self.stdout.println("newPayload: %s" % newPayload)
except:
print "Unexpected error:", sys.exc_info()[0]
return newPayload
def capitalize(data):
# A simple function that will capitalize strings
self.stdout.println("data: %s" % data)
return data.upper()
示例13: registerExtenderCallbacks
def registerExtenderCallbacks(self, callbacks):
# keep a reference to our callbacks object
self._callbacks = callbacks
# obtain an extension helpers object
self._helpers = callbacks.getHelpers()
# define stdout writer
self._stdout = PrintWriter(callbacks.getStdout(), True)
self._stdout.println(self.EXTENSION_NAME + ' by @luxcupitor')
self._stdout.println('================================')
self._stdout.println('')
self._stdout.println('TIP: Go to "Custom Scanner" tab and click "Execute on Proxy History"')
self._stdout.println('to run the scanner checks on recently imported session files.')
self._stdout.println('')
# set our extension name
callbacks.setExtensionName(self.EXTENSION_NAME)
callbacks.registerScannerCheck(self)
# add the custom tab and button to Burp's UI
self._newpanel = Panel()
self._newpanel.setLayout(FlowLayout())
self._button = JButton("Execute on Proxy History", actionPerformed=self.checkProxyHistory)
self._newpanel.add(self._button)
callbacks.customizeUiComponent(self._newpanel)
callbacks.addSuiteTab(self)
return
示例14: registerExtenderCallbacks
def registerExtenderCallbacks(self, callbacks):
# keep a reference to our callbacks object
self._callbacks = callbacks
# set our extension name
callbacks.setExtensionName("WicketRequestHandler")
callbacks.registerSessionHandlingAction(self)
# obtain our output stream
self._stdout = PrintWriter(callbacks.getStdout(), True)
self._stderr = PrintWriter(callbacks.getStderr(), True)
self._helper = callbacks.getHelpers()
return
示例15: registerExtenderCallbacks
def registerExtenderCallbacks(self, callbacks):
self.menuitems = dict()
self._callbacks = callbacks
self._helpers = callbacks.getHelpers()
callbacks.setExtensionName(EXTENSION_NAME)
callbacks.registerContextMenuFactory(self)
self._contextMenuData = None
self._stdout = PrintWriter(callbacks.getStdout(), True)
self.generate_menu_items()
return