def extract_file(self): try: un = unzip.unzip() un.extract(str(self.instance.zipfile.path) , self.path) return os.path.exists(os.path.join(self.path, 'boot.bat')) except unzip.zipfile.BadZipfile, e: logger.log_app_event(self.instance, "BadZipfile:" + str(e)) return False
def extract_file(self): try: un = unzip.unzip() un.extract(str(self.instance.zipfile.path), self.path) return os.path.exists(os.path.join(self.path, 'boot.bat')) except unzip.zipfile.BadZipfile, e: logger.log_app_event(self.instance, "BadZipfile:" + str(e)) return False
def remove_app(sender, instance, signal, *args, **kwargs): """ Deletes the uncompressed folder """ logger.log_app_event(instance, 'deleted') if instance.is_extracted and not instance.is_running: remove_dir(get_app_dir(instance)) remove_file(instance.zipfile, False) remove_file(instance.icon, False) logger.log_app_event(instance, 'removed from filesystem')
def uncompress_file(sender, instance, signal, *args, **kwargs): """ Deletes the previous version and starts the uncompressing of the file """ application_was_added = kwargs['created'] if application_was_added: logger.log_app_event(instance, 'added') else: logger.log_app_event(instance, 'edited') path = get_app_dir(instance) remove_dir(path) if instance.zipfile: from appman.utils.uncompress import UncompressThread UncompressThread(sender,instance, path, extracted_email_signal).start()
class UncompressThread(threading.Thread): """ Thread that uncompresses a certain zip file.""" def __init__(self, model, instance, path, signal): self.model = model self.instance = instance self.path = str(path) self.signal = signal threading.Thread.__init__(self) def post_signal(self, success=True): if self.signal: self.signal.send(sender=self, application=self.instance, success=success) def prepare_folder(self): if not os.path.isdir(settings.WALL_APP_DIR): os.mkdir(settings.WALL_APP_DIR) def extract_file(self): try: un = unzip.unzip() un.extract(str(self.instance.zipfile.path), self.path) return os.path.exists(os.path.join(self.path, 'boot.bat')) except unzip.zipfile.BadZipfile, e: logger.log_app_event(self.instance, "BadZipfile:" + str(e)) return False except IOError, e: logger.log_app_event(self.instance, "IO:" + str(e)) return False
def send_mail_when_app_available(sender, **kwargs): """ Sends an e-mail message informing the user that the application is ready to be used """ if 'success' in kwargs: success = kwargs['success'] else: success = True application = kwargs['application'] logger.log_app_event(application, 'deployed') email_from = settings.DEFAULT_FROM_EMAIL email_to = application.owner.email if success: message = 'Your application, %s, has been successfully deployed.' % application.name subject = '[WallManager] Application successfully deployed' else: message = """Your application, %s, was not deployed. \n Please check if the zipfile is valid, contains a boot.bat \n and follows the technical guidelines.""" % application.name subject = '[WallManager] Error deploying application.' try: send_mail(subject, message, email_from, [email_to]) except SMTPException: application.owner.message_set.create(message = message)