This gets the mime type using file-magic in a most minimal way. Since the python bindings have been available as a distro package for quite a while it is written in a way so it should also run on pre pypi installs of file-magic. This means not being able to use nice things like magic.detect_from_filename due to the fact that they where added rather recently (with recently being 2 years ago). As the mime type is only used to check for wav files that mutagen can't handle it only reads the mime type and ignores the charset and other attributes that magic can find. Due to the fact that file-magic is not properly unicode safe I'm checking the file based on it's first 2048 bytes as per <http://stackoverflow.com/questions/34836792/python-magic-cant-identify-unicode-filename#comment57418632_34838355>. This is not an issue since wav files need to start with a wav header by definition anyway. I tested this sucessfully on both CentOS and Debian with files containing Unicode in their names.
55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
from setuptools import setup
|
|
from subprocess import call
|
|
import sys
|
|
import os
|
|
|
|
# Change directory since setuptools uses relative paths
|
|
script_path = os.path.dirname(os.path.realpath(__file__))
|
|
print script_path
|
|
os.chdir(script_path)
|
|
|
|
# Allows us to avoid installing the upstart init script when deploying airtime_analyzer
|
|
# on Airtime Pro:
|
|
if '--no-init-script' in sys.argv:
|
|
data_files = []
|
|
sys.argv.remove('--no-init-script') # super hax
|
|
else:
|
|
data_files = [('/etc/init', ['install/upstart/airtime_analyzer.conf']),
|
|
('/etc/init.d', ['install/sysvinit/airtime_analyzer'])]
|
|
print data_files
|
|
|
|
setup(name='airtime_analyzer',
|
|
version='0.1',
|
|
description='Airtime Analyzer Worker and File Importer',
|
|
url='http://github.com/sourcefabric/Airtime',
|
|
author='Albert Santoni',
|
|
author_email='albert.santoni@sourcefabric.org',
|
|
license='MIT',
|
|
packages=['airtime_analyzer'],
|
|
scripts=['bin/airtime_analyzer'],
|
|
install_requires=[
|
|
'mutagen==1.31', # The Mutagen guys change stuff all the time that break our unit tests. Watch out for this.
|
|
'pika',
|
|
'daemon',
|
|
'file-magic',
|
|
'nose',
|
|
'coverage',
|
|
'mock',
|
|
'python-daemon==1.6',
|
|
'requests>=2.7.0',
|
|
'apache-libcloud',
|
|
'rgain',
|
|
'boto',
|
|
# These next 3 are required for requests to support SSL with SNI. Learned this the hard way...
|
|
# What sucks is that GCC is required to pip install these.
|
|
#'ndg-httpsclient',
|
|
#'pyasn1',
|
|
#'pyopenssl'
|
|
],
|
|
zip_safe=False,
|
|
data_files=data_files)
|
|
|
|
# Remind users to reload the initctl config so that "service start airtime_analyzer" works
|
|
if data_files:
|
|
print "Remember to reload the initctl configuration"
|
|
print "Run \"sudo initctl reload-configuration; sudo service airtime_analyzer restart\" now."
|