Python implements automatic svn checkout

Source: Internet
Author: User
Tags svn

Pyhton using Pexpect module for SVN chekout


One, install Pexpect

Pip Install Pexpect

Two, the Python script implementation

#!/usr/bin/env python# -*- coding: utf-8 -*-import pexpectusername =  ' Admin ' password =  ' passwd ' svnurl =  ' Http://mysvnurl.com/svnproject ' if __name__ ==   ' __main__ ':            svn_link =  ' svn co --username=admin  '  + svnurl +  '  . '   #  '. ' checkout  in the current directory          child = pexpect.spawn (svn_ Link)             child.expect (' Password for  \ ' admin\ ': ',  timeout=none '          #如果子程序没有在指定的时间内生成任何   Output, then  expect ()   and  read ()   will produce  TIMEOUT  exceptions.          #超时默认是  30s, available in  expect ()   and  spawn  When the constructor is initialized, it is specified as a different time, such as:         #child. Expect (' Password: ',  timeout=120)  #  wait  120s          #如果你想让  expect ()   and  read ()   Ignore timeout limit, that is, block indefinitely until there is  output  generated, set   The timeout  parameter is  none.         child.sendline (password+ ' \ n ')             child.expect (' store password unencrypted  (yes/no)? ')          child.sendline (' yes\n ')           pass


Python implements automatic svn checkout

Related Article

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.