Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from setuptools.command.install import install
- import subprocess
- from threading import Timer
- class CustomInstallCommand(install):
- """Custom install command to allow dcr installation."""
- def _install_dcr(self, install_script='install_dcr.sh'):
- print("Running DCR installer")
- command = 'sh {:s}'.format(install_script)
- try:
- install_dcr = subprocess.Popen(command.split(),
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- except OSError as error:
- print(error)
- install_timer = Timer(10, self._kill_process, [install_dcr])
- try:
- install_timer.start()
- stdout, stderr = install_dcr.communicate()
- finally:
- install_timer.cancel()
- for _line in stdout.split(b'\n'):
- print(_line.decode("utf-8"))
- for _line in stderr.split(b'\n'):
- print(_line.decode("utf-8"))
- @staticmethod
- def _kill_process(process):
- process.kill()
- def run(self):
- self._install_dcr(install_script='install_dcr.sh')
- install.run(self)
- cmdclassd = {'install': CustomInstallCommand}
- setup(....
- cmdclass=cmdclassd,
- .....)
Add Comment
Please, Sign In to add comment