salt一键部署python

1.准备工作

 

我们来看一下一键部署python的脚本。

python-file:
  file.managed:
   - source: salt://python/Python-2.7.8.tar.gz
   - name: /opt/Python-2.7.8.tar.gz
   - user: root
   - group: root

python-install:
  cmd.run:
   - name: 'cd /opt && tar zxvf Python-2.7.8.tar.gz && ln -s /opt/Python-2.7.8  /opt/python && chown -R root:root /opt/*ython*'
   - unless: 'test -d /opt/Python-2.7.8'
   - require:
     - file: python-file
 
python-rmtgz:
  file.absent:
    - name: /opt/Python-2.7.8.tar.gz
	- require:
      - cmd: python-install
	
	
/etc/profile:
  file.append:
    - text:
      - export PATH=/opt/python/bin:$PATH
	- require:
     - file: python-rmtgz
	 
/etc/ld.so.conf:
  file.append:
    - text:
      - /opt/python/lib
	- require:
     - file: python-rmtgz
	 
source-ld.so.conf:
   cmd.run:
    - name: 'ldconfig'
	- require:
      - file: /etc/ld.so.conf

  

我们查看salt的入口文件,top.sls中的内容:

2.一键部署执行命令。

 

 

s3:
..........//省略

Python-2.7.8/bin/redis-profiler
Python-2.7.8/bin/python-config
Python-2.7.8/bin/fab
Python-2.7.8/bin/easy_install
Python-2.7.8/bin/easy_install-2.7
Python-2.7.8/bin/uwsgi
Python-2.7.8/bin/django-admin
Python-2.7.8/bin/f2py
Python-2.7.8/bin/sqlformat
----------
ID: python-rmtgz
Function: file.absent
Name: /opt/Python-2.7.8.tar.gz
Result: True
Comment: Removed file /opt/Python-2.7.8.tar.gz
Started: 01:10:03.761017
Duration: 79.413 ms
Changes:
----------
removed:
/opt/Python-2.7.8.tar.gz
----------
ID: /etc/profile
Function: file.append
Result: True
Comment: File /etc/profile is in correct state
Started: 01:10:03.840725
Duration: 3.981 ms
Changes:
----------
ID: /etc/ld.so.conf
Function: file.append
Result: True
Comment: File /etc/ld.so.conf is in correct state
Started: 01:10:03.844890
Duration: 1.775 ms
Changes:
----------
ID: source-ld.so.conf
Function: cmd.run
Name: ldconfig
Result: True
Comment: Command "ldconfig" run
Started: 01:10:03.846813
Duration: 16.212 ms
Changes:
----------
pid:
28582
retcode:
0
stderr:
stdout:

Summary for s3
------------
Succeeded: 6 (changed=4)
Failed: 0
------------
Total states run: 6
Total run time: 35.878 s

  这样我们去s2机器上就可以看到jdk已经安装成功了。

 

转载于:https://www.cnblogs.com/wyl9527/p/6859728.html

### 如何在 Python 中添加或去除 Salt 噪声 #### 添加 Salt 噪声 为了高效地向图像中添加椒盐噪声,可以采用基于 `NumPy` 的方法来避免逐像素遍历带来的低效问题。下面是一个高效的实现方式: ```python import numpy as np import cv2 def add_salt_noise(image: np.ndarray, prob=0.01): """ 向图像中添加椒盐噪声。 参数: image (np.ndarray): 输入图像数组. prob (float): 发生概率,默认为 0.01. 返回: np.ndarray: 加入噪声后的图像. """ noisy_image = np.copy(image) # 计算要改变的像素数量 num_salt = int(prob * image.size * 0.5) # 随机选取位置设置为最大值(白色噪点) coords = [np.random.randint(0, i - 1, num_salt) for i in image.shape[:2]] noisy_image[tuple(coords)] = 255 return noisy_image ``` 此代码片段展示了如何使用 NumPy 来更有效地创建含有特定百分比椒盐噪声的新图像副本[^3]。 #### 去除 Salt 噪声 对于去除此种类型的噪声,通常推荐使用中值滤波器(`medianBlur`),因为其能够很好地保留边缘特征的同时平滑掉孤立的黑白点。以下是具体的应用实例: ```python def remove_salt_noise(image: np.ndarray, kernel_size=(3, 3)): """ 使用中值滤波移除图像中的椒盐噪声。 参数: image (np.ndarray): 输入含噪声的图像数据. kernel_size(tuple): 滤波窗口大小,默认为 (3, 3). 返回: np.ndarray: 经过处理后较为干净的图像. """ cleaned_image = cv2.medianBlur(image, ksize=max(kernel_size)) return cleaned_image ``` 上述函数通过调用 OpenCV 库提供的 `cv2.medianBlur()` 方法实现了对输入图片的有效降噪处理[^1]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值