Skip to main content

Provides some useful functions to write maintainer scripts or deployment scripts

Project description

pybee

pybee 提供一些辅助函数,方便使用 Python 来写系统维护/部署脚本, 使用 Bash 写维护/部署脚本实在不爽;例如提供 sed、awk 工具对应的功能函数,但 pybee 目标不是编写一个 python 版的 sed/awk 工具

编译

安装依赖工具

  • python 3.4+
  • poetry

执行下面命令安装依赖包

poetry install

编译

poetry build

pybee 模块

pybee 模块封装了或者增加常见系统维护需要的函数

  • pybee.path 增强 os.path 模块的一些函数
  • pybee.compress 封装 zip/tar.gz 压缩函数
  • pybee.sed 提供 sed 工具类似功能的函数
  • pybee.ask 封装在 termia 常见交互操作的函数
  • pybee.importutil 提供把一个 py 文件当作模块 import 的函数

还有其他模块,这里就不一一列出

pybee.action 模块

在 pybee 模块的基础上把常见的操作封装成 action,下面就是一个列子

import pybee

ac = pybee.action.ActionContext([
  ('SCRIPT_DIR', pybee.path.get_script_path(__file__)),
  ('DIST_DIR', '$CURRENT_DIR/dist'),
  ('OUT_PUT_DIR', '$DIST_DIR/test-demo-portable'),
])

ac.prepare_dir(
  [
      '$DIST_DIR', '$OUT_PUT_DIR',
      '$OUT_PUT_DIR/portable',
  ]
)

ac.check_bin([
  ('gradle','please install gradle', 'GRADLE_BIN'),
])

ac.exec_cmd(
  [
      '$GRADLE_BIN', 'packDist', '-x', 'test'
  ]
)

ac.unzip(
  '$DIST_DIR/test-demo/test-demo.jar',
  '$OUT_PUT_DIR'
)


def ignore_config_files(src, names):
  return ['project.groovy', ]

ac.copy(
  [
      ('$CURRENT_DIR/config', '$OUT_PUT_DIR', {
          'ignore': ignore_config_files
      }),
      ('$CURRENT_DIR/public', '$OUT_PUT_DIR'),
  ]
)

ac.copy(
  [
      ('run.ps1', '$OUT_PUT_DIR'),
      ('run.sh', '$OUT_PUT_DIR'),
      ('portable.groovy', '$OUT_PUT_DIR/config'),
  ],
  work_dir='$SCRIPT_DIR/portable'
)

ac.zip(
  '$OUT_PUT_DIR',
  '$DIST_DIR/test-demo-portable-{datetime}.zip',
  env_name='DIST_FILE'
)


def print_success(context):
  print('')
  zip_file = context.get_env('DIST_FILE')
  print('pack successfully, dist file is %s' % zip_file)


ac.execute(succ_func=print_success)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybee-0.3.2.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

pybee-0.3.2-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file pybee-0.3.2.tar.gz.

File metadata

  • Download URL: pybee-0.3.2.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.16 CPython/3.7.3 Linux/4.4.0-17763-Microsoft

File hashes

Hashes for pybee-0.3.2.tar.gz
Algorithm Hash digest
SHA256 6858783e709266dca9cf0071b14a480e662ec8fda11e3b68d5fb4cf176067669
MD5 ed60726b7aeeb9ee5b03ace06230d899
BLAKE2b-256 157c540c186dda457e5fa6e89185774f4884817629efd832aea7d2101bbf0f04

See more details on using hashes here.

File details

Details for the file pybee-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: pybee-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 23.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.16 CPython/3.7.3 Linux/4.4.0-17763-Microsoft

File hashes

Hashes for pybee-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a9385e3c131952ab6b925ad434ae26cefa1aeee230d7e980d116f1ce96ddf0cc
MD5 c45738c2ece5fce0f586df6e6d453b6a
BLAKE2b-256 bc6504a1e5efc75a94cc102d28ef07887915c79a281baa64b73ad6e812beda2c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page