| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
# Copyright 2014 (C) Raster Software Vigo (Sergio Costas) |
| 4 |
# |
| 5 |
# This file is part of DeVeDe-NG |
| 6 |
# |
| 7 |
# DeVeDe-NG is free software; you can redistribute it and/or modify |
| 8 |
# it under the terms of the GNU General Public License version 3 |
| 9 |
# as published by the Free Software Foundation. |
| 10 |
# |
| 11 |
# DeVeDe-NG is distributed in the hope that it will be useful, |
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
# GNU General Public License for more details. |
| 15 |
# |
| 16 |
# You should have received a copy of the GNU General Public License |
| 17 |
# along with this program. If not, see <http://www.gnu.org/licenses/> |
| 18 |
|
| 19 |
import devedeng.executor |
| 20 |
import subprocess |
| 21 |
|
| 22 |
|
| 23 |
class avbase(devedeng.executor.executor): |
| 24 |
|
| 25 |
def check_version(self, cmd): |
| 26 |
|
| 27 |
try: |
| 28 |
handle = subprocess.Popen( |
| 29 |
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 30 |
(stdout, stderr) = handle.communicate() |
| 31 |
if 0 != handle.wait(): |
| 32 |
return False |
| 33 |
except: |
| 34 |
return False |
| 35 |
self.check_version_txt(stdout) |
| 36 |
|
| 37 |
def check_version_txt(self, vtext): |
| 38 |
|
| 39 |
self.major_version = 0 |
| 40 |
self.minor_version = 0 |
| 41 |
|
| 42 |
for line in vtext: |
| 43 |
if not isinstance(line, str): |
| 44 |
continue |
| 45 |
if (line.startswith("avconv version")): |
| 46 |
pos1 = line.find('.', 15) |
| 47 |
pos2 = line.find('-', 15) |
| 48 |
if (pos2 == -1): |
| 49 |
return False |
| 50 |
try: |
| 51 |
if (pos1 == -1): |
| 52 |
major = int(line[15:pos2].strip()) |
| 53 |
minor = 0 |
| 54 |
else: |
| 55 |
major = int(line[15:pos1].strip()) |
| 56 |
minor = int(line[pos1 + 1:pos2].strip()) |
| 57 |
except: |
| 58 |
return False |
| 59 |
self.major_version = major |
| 60 |
self.minor_version = minor |
| 61 |
return True |
| 62 |
return False |