Python program to push files into Bitbucket.org

Here I am going to show you a simple program, using which you can add files to your bibucket repository. If you are using Linux operating system, then go to terminal and run this program. When you are asked to input username and password please input your bitbucket username and password correspondingly. When you are asked to enter reponame give your bitbucket repository name as it is.

import shlex, subprocess
from subprocess import call

print 'Enter repository address :' 
repo = raw_input()
call("hg clone "+repo, shell=True)

print 'Enter filenames to copy :'
fnames = raw_input()
files_list=shlex.split(fnames)

print'Enter reponame'
reponame = raw_input()

print 'copying to repository'
for i in range(len(files_list)):
	call(["cp",files_list[i],reponame])

print'adding'
subprocess.Popen(["hg", "add"],cwd=reponame)

print'Enter Username of bitbucket'
username = raw_input()
print'Enter a  passphrase'
passphrase = raw_input()

print 'committing added files'
subprocess.Popen(["hg","commit","-u",username,"-Am",passphrase],
                                                          cwd=reponame)

print'Pushing files to repository'
print'Enter username'
proc=subprocess.Popen(["hg","push"],cwd=reponame,stdout=subprocess.PIPE,)
stdout_value=proc.communicate()[0]

print' program finishing...files are uploaded...'
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s