Python-fabric Introduction

Source: Internet
Author: User

1-fabric

Fabric is a Python library that provides a rich interface for interfacing with SSH, which can be used to automate and streamline execution of shell commands on local or remote machines.

Ideal for remote deployment and system maintenance for applications. Simple to use, just understand basic shell commands.

    • homepage:http://www.fabfile.org/
    • docs:http://docs.fabfile.org/
    • github:https://github.com/fabric/fabric/
    • Changelog:http://www.fabfile.org/changelog.html
2-Version differentiation

Currently, the main fabric libraries from pypi can be searched for "fabric 2.1.3", "Fabric2 2.1.3" and "Fabric3 1.14.post1".

    • Fabric: Official fabric, compatible with Python 2 & Python 3, but not compatible with fabric 1.x fabfile;
    • fabric2: Same as fabric, only as a smooth migration (install 1.x version using fabric package, install 2.x version with FABRIC2 package to achieve 1.x and 2.x coexistence);
    • Fabric3: is a fabric 1.x-based fork, compatible with Python2 & Python3, compatible with fabric1.x Fabfile;

the main differences between Fabric 1.x and 2.x versions:
    • Fabric 1.x supports only python2.5-2.7, while Fabric2 supports Python (2.7, 3.4+);
    • Fabric 2.x is a rewrite of the fabric 1.x version, no longer compatible with the 1.x version of Fabfile, and some modules and usage has changed a lot;
    • For specific information, see: Rewrite for 2.0! See Upgrading from Fabric 1.x
3-About FABRIC3FABRIC3 is a Python (2.7 or 3.4+) library and command-line tool for streamlining the use of SSH for Applicati On deployment or systems administration tasks. This was a fork of the original Fabric (GIT) with the intention of providing support for PYTHON3, while maintaining support For all non-archaic versions of Python2. GitHub: https://pypi.org/project/Fabric3/ Homepage: https://github.com/mathiasertl/fabric/ Note
    • The current version of "Fabric3 1.14.post1" features and how to use it still with "Fabric 1.x." Basically consistent.
    • Before installing FABRIC3, you need to uninstall fabric first.
1 $ pip2 Uninstall Fabric2$ pip2InstallFABRIC3--proxy="10.144.1.10:8080"3 4 $ pip2 Show fabric35 name:fabric36Version:1.14. Post17Summary:fabric is a simple, pythonic tool forRemote execution and deployment (py2.7/py3.4+compatible fork).8Home-page:https://github.com/mathiasertl/fabric/9 Author:mathias ErtlTenauthor-Email: [Email protected] One License:unknown Alocation:c:\python27\lib\site-Packages - Requires:paramiko, six -Required-by:

4-Problem Handling 1-Import Fabric.api prompt error "No module named API"
1  from Import Run 2 Traceback (most recent): 3   " <stdin> "  in <module>4importerror:no module named API5 >>>

Processing method:

Verify the fabric version information, the "from Fabric.api import Run" method only applies to the fabric1.x version.

2-run the Fabric sample prompt for an error "No idea what ' hello ' is! '

1 $ cat fabfile.py2 #Coding:utf-83 4 5 defHello ():6         Print("Hello fabric!")7 8 $ fab Hello9No idea what'Hello'  is!Ten  One$ FAB--List ANo Tasks foundinchCollection'Fabfile'!
Processing method: Confirm Fabric Version information, fabric2.x version is incompatible with fabric 1.x fabfile.  Follow the fabric 2.x requirements to change the Fabfile file content format and run it again. Specific information can be viewed: http://docs.fabfile.org/en/2.1/getting-started.html#addendum-the-fab-command-line-tool
1 $ pip Show Fabric2 Name:fabric3version:2.1.34 summary:high level SSH command Execution5home-page:http://fabfile.org6 Author:jeff Forcier7author-Email: [Email protected]8 License:bsd9location:c:\python27\lib\site-PackagesTen Requires:paramiko, invoke, cryptography Onerequired-by : A  - $ cat fabfile.py -  fromInvokeImportTask the  - @task - defHello (c): -C.run ("echo ' Hello fabric '") +         Print("Hello fabric!") -  + $ A  at$ FAB--List - Available tasks: -  - Hello -  -  in $ fab Hello - 'Hello Fabric' to Hello fabric! +  -$

5-Reference information The following are primarily for fabric 1.x and Fabric3.
    • [Python Remote deployment tool fabric detailed] (http://python.jobbole.com/87241/)
    • [Fabric for remote operation and deployment] (http://python.jobbole.com/83716/)
    • English Document: http://fabric-chs.readthedocs.io/zh_CN/chs/
    • [Python module learning-fabric] (https://www.cnblogs.com/xiao-apple36/p/9124292.html)

Python-fabric Introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.