浏览代码

Use subprocess to call stty size when COLUMNS is not set

Philipp Hagemeister 14 年之前
父节点
当前提交
4f2a5e06da
共有 1 个文件被更改,包括 6 次插入5 次删除
  1. 6 5
      youtube-dl

+ 6 - 5
youtube-dl

@@ -2996,11 +2996,12 @@ def parseOpts():
 		if columns:
 		if columns:
 			return int(columns)
 			return int(columns)
 
 
-		# TODO: Breaks on phihag's system
-		#if sys.platform.startswith('linux'):
-		#	try:
-		#		return os.popen('stty size', 'r').read().split()[1]
-		#	except: pass
+		try:
+			sp = subprocess.Popen(['stty', 'size'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+			out,err = sp.communicate()
+			return out.split()[1]
+		except:
+			pass
 		return None
 		return None
 
 
 	max_width = 80
 	max_width = 80