Mercurial > hg > config
annotate python/pbmoz.py @ 454:f7c49c61f092
python/setup_repo.py
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 10 Aug 2013 17:53:33 -0700 |
parents | c1390e43b437 |
children |
rev | line source |
---|---|
158
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
2 import urllib, sys |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
3 |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
4 if len(sys.argv) == 2: |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
5 url = "http://%s.pastebin.mozilla.org" % sys.argv[1] |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
6 fmt = sys.argv[1] |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
7 else: |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
8 url = "http://pastebin.mozilla.org" |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
9 fmt = "None" |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
10 |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 body = sys.stdin.read() |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
13 params = [ |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
14 ('parent_pid', ''), |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
15 ('code2', body), |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
16 ('poster', ''), |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
17 ('expiry', 'd'), |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
18 ('paste', 'Send'), |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
19 ('format', fmt), |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
20 ] |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
21 |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
22 data = urllib.urlencode(params) |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
23 |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
24 req = urllib.urlopen(url, data) |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
25 |
c1390e43b437
point pastebin at pastebin.mozilla
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
26 print req.geturl() |