Make sure you wrap the PHP code with <?php and ?>
<?php highlight_string('<?php // ... Some code ?>'); ?>
Make sure you wrap the PHP code with <?php and ?>
<?php highlight_string('<?php // ... Some code ?>'); ?>
In order to do this, you must position the parent box relative, you don’t need to set the left/right or top/bottom necessarily, just a:
.ab-parent-box { position: relative; }
Will do the trick…
Right click on it and click “Run as Admin…”
To send HTML emails, you will need special email headers:
$headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: FROM-EMAIL@YOURDOMAIN.COM\r\n" ."Reply-To: REPLY-EMAIL@YOURDOMAIN.COM"; mail('TO EMAIL ADDRESS', 'SUBJECT LINE', 'Message Body<br /><small>With some HTML</small>', $headers);
$uid = uniqid();
import os if os.path.exists(path_to_file): # Do stuff
if (file_exists($path_to_file)) { // Do stuff }
import flash.external.ExternalInterface; ... ExternalInterface.call("your_javascript_function()");
Get the return value:
var x:int = ExternalInterface.call("get_x()");
It would be nice to be able to kill threads anytime you wanted, there are solutions to this but are not part of the Python library and I didn’t yet get a chance to try them… Actually there is only one promising solution to this.
The other thing I would love to have in Python is to be able to call popen with a second parameter which is a timeout, That is (obviously) popen would give up and return if the call was taking more than x number of seconds…
I was working on a piece of code that was supposed to close a bunch of processes ‘with the same name’ right after each other and was getting this error message:
pywintypes.error: (5, ‘TerminateProcess’, ‘Access is denied.’)
The problem was that I was doing this in a loop and Windows didn’t get enough time to close the first process yet. To fix this, just add a time.sleep(0.5) in your loop and you will be all set…
I hope this helps
Here is the code I’m using (found in Python mailing list):
import time import win32api, win32pdhutil, win32con import win32pdh, string # *********************************************************************** # *********************************************************************** def GetAllProcesses(): object = "Process" items, instances = win32pdh.EnumObjectItems(None,None,object, win32pdh.PERF_DETAIL_WIZARD) return instances # *********************************************************************** # *********************************************************************** # *********************************************************************** def GetProcessID ( name ) : object = "Process" items, instances = win32pdh.EnumObjectItems(None,None,object, win32pdh.PERF_DETAIL_WIZARD) val = None if name in instances : hq = win32pdh.OpenQuery() hcs = [] item = "ID Process" path = win32pdh.MakeCounterPath( (None,object,name, None, 0, item) ) hcs.append(win32pdh.AddCounter(hq, path)) win32pdh.CollectQueryData(hq) time.sleep(0.01) win32pdh.CollectQueryData(hq) for hc in hcs: type, val = win32pdh.GetFormattedCounterValue(hc, win32pdh.PDH_FMT_LONG) win32pdh.RemoveCounter(hc) win32pdh.CloseQuery(hq) return val # *********************************************************************** # *********************************************************************** # *********************************************************************** def Kill_Process_pid ( pid ) : handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, pid) #get process handle win32api.TerminateProcess(handle, -1) #kill by handle win32api.CloseHandle(handle) #close api # *********************************************************************** # *********************************************************************** # *********************************************************************** def Kill_Process ( name ) : pid = GetProcessID(name) if pid: try: Kill_Process_pid(pid) return True except: pass else: return False # ***********************************************************************
I just modified the last function, it’s kind of funny I know but that works for me, then I call it like:
print 'Killing IEs...', while Kill_Process('iexplore'): time.sleep(0.5) print 'Done!'