How to use the vidgear.gears.helper.check_python_version function in vidgear

To help you get started, we’ve selected a few vidgear examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github abhiTronix / vidgear / tests / test_helper.py View on Github external
def test_download_ffmpeg_linux(path = tempfile.gettempdir()):
	if os.name != 'nt':
		try:
			#inialize varibles
			file_url = 'https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-{}-static.tar.xz'.format(getBitmode(False))
			file_name = os.path.join(os.path.abspath(path),'ffmpeg-release-{}-static.tar.xz'.format(getBitmode(False)))
			file_path = os.path.join(os.path.abspath(path), 'ffmpeg-4.1.3-{}-static/ffmpeg'.format(getBitmode(False)))
			base_path, _ = os.path.split(file_path) #extract file base path

			#check if file already exists
			if os.path.isfile(file_path):
				pass #skip download if does 
			else:
				import requests
				
				if check_python_version() == 2:

					from backports import lzma

				import tarfile

				#check if given pth has write access
				assert os.access(path, os.W_OK), "Permission Denied: Cannot write ffmpeg binaries to directory = " + path
				#remove leftovers
				if os.path.isfile(file_name):
					os.remove(file_name)
				#download and write file to the given path

				with open(file_name, "wb") as f:
					response  = requests.get(file_url, stream=True)
					total_length = response.headers.get('content-length')
					if total_length is None: # no content length header
github abhiTronix / vidgear / tests / test_writegear.py View on Github external
with open(file_name, "wb") as f:
					response  = requests.get(file_url, stream=True)
					total_length = response.headers.get('content-length')
					if total_length is None: # no content length header
						f.write(response.content)
					else:
						dl = 0
						total_length = int(total_length)
						for data in response.iter_content(chunk_size=4096):
							dl += len(data)
							f.write(data)
							done = int(50 * dl / total_length)
							sys.stdout.write("\r[{}{}]{}{}".format('=' * done, ' ' * (50-done), done * 2, '%') )    
							sys.stdout.flush()
				print("\nExtracting executables, Please Wait...")
				if check_python_version()==2:
					with lzma.LZMAFile(file_name, "r") as f:
						with tarfile.open(fileobj=f) as tar:
							tar.extractall(base_path)			
				else:
					with tarfile.open(file_name, 'r:xz') as tar:
						tar.extractall(base_path)
						tar.close()
				print("\nChecking Files...")
				if os.path.isfile(file_path):
					pass
				else:
					folder = os.path.join(os.path.abspath(os.path.join(file_path ,"..")), 'ffmpeg-4.1.3-{}-static'.format(getBitmode(False)))
					folder_dest = os.path.abspath(os.path.join(file_path ,".."))
					files = os.listdir(folder)
					for file in files:
						shutil.move(os.path.join(folder, file), folder_dest)