Skip to content
Snippets Groups Projects
Commit b283e57a authored by nimrod's avatar nimrod
Browse files

Changed folder structure.

Automated build, publish and clean using Fabric.
Added dependency python3-vlc, another packages I publish from VLC source (python3 binding to libvlc).
parent 9cd26106
Branches
Tags
No related merge requests found
......@@ -5,5 +5,5 @@ debian/dcpman.links
debian/dcpman.postinst.debhelper
debian/dcpman.prerm.debhelper
debian/dcpman.substvars
dcpman/__pycache__
dcpman/ui.py
source/__pycache__
source/ui.py
dcpman (0.1.1) UNRELEASED; urgency=medium
* Adding better detection of encrypted DCPs by using avprobe to try and read the mxf files (still not 100% correct).
-- Nimrod Adar <nimrod@nimrod.private> Mon, 14 Jul 2014 13:11:42 +0300
dcpman (0.1) UNRELEASED; urgency=medium
* Initial release.
-- Nimrod Adar <nimrod@shore.co.il> Sun, 29 Jun 2014 16:19:53 +0300
......@@ -7,7 +7,7 @@ X-Python3-Version: >= 3.2
Standards-Version: 3.9.5.0
Package: dcpman
Depends: python3 (>= 3.2), python3-pyqt4 | python3-pyqt5, oxygen-icon-theme
Depends: python3 (>= 3.2), python3-pyqt4 | python3-pyqt5, oxygen-icon-theme, python3-vlc
Architecture: all
Description: Management tool for Digital Cinema Packages.
A tool to manage DCPs (Digital Cinema Packages), although currently it only
......
dcpman_0.1_all.deb video optional
dcpman_0.1.1_all.deb video optional
dcpman/* usr/lib/python3/dist-packages/dcpman
dcpman.desktop usr/share/applications
source/*.py usr/lib/python3/dist-packages/dcpman
source/dcpman.desktop usr/share/applications
#!/usr/bin/make -f
%:
pyuic4 dcpman.ui > dcpman/ui.py
pyuic4 source/dcpman.ui > source/ui.py
dh $@ --with python3
#!/usr/bin/env python
from fabric.api import task, local
@task
def publish ():
build ()
for dist in ['wheezy', 'jessie', 'sid']:
local ('''reprepro includedeb ''' + dist + ''' ../dcpman_*.deb''')
@task
def build ():
local ('''dpkg-buildpackage''')
@task
def clean ()
local ('''rm ../dcpman_*''')
File moved
......@@ -4,6 +4,7 @@ from base64 import b64encode
from os import stat, listdir
from xml.dom.minidom import parse
import sys
import vlc
class Asset(object):
'''A simple asset that's part of whole DCP package.'''
......@@ -31,8 +32,15 @@ class Asset(object):
hash.update(buffer)
buffer = fh.read(buffersize)
return(self.hash == b64encode (hash.digest()).decode())
def add_duration (self):
if hasattr (self, 'type') and self.type.find ('mxf') > -1:
instance = vlc.Instance ()
media = instance.media_new ('file://' + self.fullpath)
media.parse ()
self.duration = media.get_duration ()
def __init__(self, rootpath, filename, id=None, hash=None, size=None, packinglist=False):
def __init__(self, rootpath, filename, id=None, hash=None, size=None, packinglist=False, type=None):
'''Initialize an asset, has to have a filename and path.'''
self.rootpath = rootpath
if filename[0:8] == 'file:///':
......@@ -45,6 +53,8 @@ class Asset(object):
self.hash = hash
if size != None:
self.size = size
if type != None:
self.type = type
self.packinglist = packinglist
......@@ -76,35 +86,44 @@ class DCP:
asset.filename) from e
return True
def __init__(self, directory):
'''Parses the DCP in the directory specified.'''
self.root = directory
if 'ASSETMAP.xml' in listdir(directory):
def _parse_assetmap (self):
'''Adds the asset map file to the list of assets and parses it.'''
if 'ASSETMAP.xml' in listdir(self.directory):
filename = 'ASSETMAP.xml'
elif 'ASSETMAP' in listdir(directory):
elif 'ASSETMAP' in listdir(self.directory):
filename = 'ASSETMAP'
else:
raise RuntimeError ('Couldn\'t find assetmap file')
self.assets = [Asset(directory, filename)]
self.assets = [Asset(self.directory, filename, type='text/xml')]
assetmap = self.assets[0].fullpath
if 'VOLINDEX.xml' in listdir(directory):
filename = 'VOLINDEX.xml'
elif 'VOLINDEX' in listdir(directory):
filename = 'VOLINDEX'
#else:
#raise RuntimeError ('Couldn\'t find volindex file')
self.assets.append(Asset(directory, filename))
try:
assetmap = parse(assetmap).getElementsByTagName('Asset')
self.assets.append(Asset(directory, filename))
self.assets.append(Asset(self.directory, filename))
for element in assetmap:
id = element.getElementsByTagName('Id')[0].firstChild.data
id = id.split(':')[-1]
filename = element.getElementsByTagName('Path')[0].firstChild.data
packinglist = len(element.getElementsByTagName('PackingList')) > 0
self.assets.append(Asset(directory, filename, id=id, packinglist=packinglist))
if packinglist:
self.assets.append(Asset(self.directory, filename, id=id, packinglist=packinglist, type='text/xml'))
else:
self.assets.append(Asset(self.directory, filename, id=id, packinglist=packinglist))
except BaseException as e:
raise RuntimeError ('Failed to parse assetmap file') from e
def _add_volindex (self):
'''Adds the volume index file to the list of assets.'''
if 'VOLINDEX.xml' in listdir(self.directory):
filename = 'VOLINDEX.xml'
elif 'VOLINDEX' in listdir(self.directory):
filename = 'VOLINDEX'
else:
#raise RuntimeError ('Couldn\'t find volindex file')
return
self.assets.append(Asset(self.directory, filename, type='text/xml'))
def _parse_packinglist (self):
'''Parses the packing list.'''
try:
pkls = (parse(x.fullpath) for x in self.assets if x.packinglist)
for pkl in pkls:
......@@ -119,13 +138,27 @@ class DCP:
id = element.getElementsByTagName('Id')[0].firstChild.data
id = id.split(':')[-1]
hash = element.getElementsByTagName('Hash')[0].firstChild.data
type = element.getElementsByTagName('Type')[0].firstChild.data
size = int(element.getElementsByTagName('Size')[0].firstChild.data)
asset = [x for x in self.assets if hasattr(x, 'id') and x.id == id][0]
asset.hash = hash
asset.size = size
asset.type = type
asset.add_duration ()
except BaseException as e:
raise RuntimeError ('Failed to parse packinglist file') from e
def __init__(self, directory):
'''Parses the DCP in the directory specified.'''
self.directory = directory
self._parse_assetmap ()
self._add_volindex ()
self._parse_packinglist ()
try:
self.duration = max ([x.duration for x in self.assets if hasattr (x, 'duration')])
except:
pass
if __name__ == '__main__':
if (len(sys.argv) == 2):
......@@ -140,6 +173,7 @@ if __name__ == '__main__':
print ('DCP is signed')
else:
print ('DCP is unsigned')
print ('Duration:', dcp.duration)
if (dcp.verify()):
print ('Verification succeeded.')
else:
......
File moved
......@@ -19,7 +19,7 @@
<rect>
<x>11</x>
<y>11</y>
<width>491</width>
<width>501</width>
<height>131</height>
</rect>
</property>
......@@ -30,7 +30,7 @@
<widget class="QLabel" name="nameLabel">
<property name="minimumSize">
<size>
<width>45</width>
<width>65</width>
<height>0</height>
</size>
</property>
......@@ -54,20 +54,20 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="signedLabel">
<widget class="QLabel" name="encryptedLabel">
<property name="minimumSize">
<size>
<width>45</width>
<width>65</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Signed</string>
<string>Encrypted</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="signedLine">
<widget class="QLineEdit" name="encryptedLine">
<property name="frame">
<bool>true</bool>
</property>
......@@ -84,7 +84,7 @@
<widget class="QLabel" name="verifyLabel">
<property name="minimumSize">
<size>
<width>45</width>
<width>65</width>
<height>0</height>
</size>
</property>
......
#!/usr/bin/env python3
from PyQt4 import QtGui
from PyQt4 import QtCore
from dcpman.dcp import DCP
from dcpman import ui #autogenerated file from Qt Designer to setup the window
#from dcpman.dcp import DCP
#from dcpman import ui #autogenerated file from Qt Designer to setup the window
from dcp import DCP
import ui
import sys
class verifyThread(QtCore.QThread):
......@@ -51,10 +53,12 @@ if __name__ == '__main__':
window.nameLine.setText(dcp.name)
except AttributeError:
window.nameLine.setText(directory.split('/')[-1])
if dcp.signed:
window.signedLine.setText('Signed')
if dcp.signed and dcp.duration == 0:
window.encryptedLine.setText('Most likely')
elif dcp.signed or dcp.duration == 0:
window.encryptedLine.setText ('Probably')
else:
window.signedLine.setText('Not signed')
window.encryptedLine.setText('Probably not')
window.verifyLine.setText('Click button to start verification')
window.verifyButton.clicked.connect(verify_in_thread)
except BaseException as exception:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment