Can anyone give me python code from php code?

By MitGuru

Can anyone give me python script from bellow php script?
i want to convert php script to python.
this script run cmd in php and give the output buffer. i want to run same code in python so please help me and convert bellow php script to paython.
Thanks in advance.

$pipearray = array(1 => array('pipe', 'w'));
if (is_resource($process = proc_open($cmd, $pipearray, $pipes))){
   header('Content-Length: 10000'));
   header('Content-Type: application/octet-stream');
   header('Content-Disposition: attachment; filename="file.mp3"');
   header('Connection: Close');
// Activate flush
if (function_exists('apache_setenv')){
   apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', false);
ini_set('implicit_flush', true);
while (!feof($pipes[1])) {
  $buffer = fread($pipes[1], 1024 * 16);
  // Print buffer
  echo $buffer;
  // Provide mp3 audio as chunks
  if (ob_get_length() > 0) ob_flush();
// Close pipes
// Close process

Source: Stack Overflow


Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273