def _deploy_archive(self, current_work_dir, payload, payload_name): """ Creates a temporary file containing the archive and decompresses it into a temporary directory. The directory is scanned for Distutils2 modules, each is then copied over to the work directory and hot-(re)loaded. """ with NamedTemporaryFile(prefix='zato-hd-', suffix=payload_name) as tf: tf.write(payload) tf.flush() tmp_dir = mkdtemp(prefix='zato-hd-') decompress(tf.name, None) for tmp_py_path in visit_py_source_from_distribution(tmp_dir): # Get the path the stuff needs to be copied over to and create # all the directories needed along dest_py_path = os.path.join( current_work_dir, os.path.relpath(tmp_py_path, tmp_dir)) dest_py_dir = os.path.dirname(dest_py_path) try: os.mkdir(dest_py_dir) except OSError, e: if e.errno != EEXIST: raise self._deploy_file(current_work_dir, open(tmp_py_path).read(), dest_py_path) # Clean up shutil.rmtree(tmp_dir)
def import_services_from_directory(self, dir_name): """ dir_name points to a Distutils2 directory. Its setup.cfg file is read and all the modules from packages pointed to by the 'files' section are scanned for services. """ for py_path in visit_py_source_from_distribution(dir_name): self.import_services_from_file(py_path, False, None)
def _deploy_archive(self, current_work_dir, payload, payload_name): """ Creates a temporary file containing the archive and decompresses it into a temporary directory. The directory is scanned for Distutils2 modules, each is then copied over to the work directory and hot-(re)loaded. """ with NamedTemporaryFile(prefix='zato-hd-', suffix=payload_name) as tf: tf.write(payload) tf.flush() tmp_dir = mkdtemp(prefix='zato-hd-') decompress(tf.name, None) for tmp_py_path in visit_py_source_from_distribution(tmp_dir): # Get the path the stuff needs to be copied over to and create # all the directories needed along dest_py_path = os.path.join(current_work_dir, os.path.relpath(tmp_py_path, tmp_dir)) dest_py_dir = os.path.dirname(dest_py_path) try: os.mkdir(dest_py_dir) except OSError, e: if e.errno != EEXIST: raise self._deploy_file(current_work_dir, open(tmp_py_path).read(), dest_py_path) # Clean up shutil.rmtree(tmp_dir)