Bug 1480362 - Remove |./mach pastebin| command now that the service is no longer available. r=firefox-build-system-reviewers,nalexander

Differential Revision: https://phabricator.services.mozilla.com/D19085

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Chris Manchester 2019-02-08 19:50:29 +00:00
parent feb49e49fa
commit 2a2d1b1a0e

View File

@ -75,97 +75,19 @@ class UUIDProvider(object):
print((' { ' + '0x%s, ' * 7 + '0x%s } }') % pairs)
def REMOVED(cls):
"""Command no longer exists!
This functionality is no longer supported in mach.
"""
return False
@CommandProvider
class PastebinProvider(object):
@Command('pastebin', category='misc',
description='Command line interface to pastebin.mozilla.org.')
@CommandArgument('--language', default=None,
help='Language to use for syntax highlighting')
@CommandArgument('--poster', default='',
help='Specify your name for use with pastebin.mozilla.org')
@CommandArgument('--duration', default='day',
choices=['d', 'day', 'm', 'month', 'f', 'forever'],
help='Keep for specified duration (default: %(default)s)')
@CommandArgument('file', nargs='?', default=None,
help='Specify the file to upload to pastebin.mozilla.org')
def pastebin(self, language, poster, duration, file):
import urllib
import urllib2
URL = 'https://pastebin.mozilla.org/'
FILE_TYPES = [{'value': 'text', 'name': 'None', 'extension': 'txt'},
{'value': 'bash', 'name': 'Bash', 'extension': 'sh'},
{'value': 'c', 'name': 'C', 'extension': 'c'},
{'value': 'cpp', 'name': 'C++', 'extension': 'cpp'},
{'value': 'html4strict', 'name': 'HTML', 'extension': 'html'},
{'value': 'javascript', 'name': 'Javascript', 'extension': 'js'},
{'value': 'javascript', 'name': 'Javascript', 'extension': 'jsm'},
{'value': 'lua', 'name': 'Lua', 'extension': 'lua'},
{'value': 'perl', 'name': 'Perl', 'extension': 'pl'},
{'value': 'php', 'name': 'PHP', 'extension': 'php'},
{'value': 'python', 'name': 'Python', 'extension': 'py'},
{'value': 'ruby', 'name': 'Ruby', 'extension': 'rb'},
{'value': 'css', 'name': 'CSS', 'extension': 'css'},
{'value': 'diff', 'name': 'Diff', 'extension': 'diff'},
{'value': 'ini', 'name': 'INI file', 'extension': 'ini'},
{'value': 'java', 'name': 'Java', 'extension': 'java'},
{'value': 'xml', 'name': 'XML', 'extension': 'xml'},
{'value': 'xml', 'name': 'XML', 'extension': 'xul'}]
lang = ''
if file:
try:
with open(file, 'r') as f:
content = f.read()
# TODO: Use mime-types instead of extensions; suprocess('file <f_name>')
# Guess File-type based on file extension
extension = file.split('.')[-1]
for l in FILE_TYPES:
if extension == l['extension']:
print('Identified file as %s' % l['name'])
lang = l['value']
except IOError:
print('ERROR. No such file')
return 1
else:
content = sys.stdin.read()
duration = duration[0]
if language:
lang = language
params = [
('parent_pid', ''),
('format', lang),
('code2', content),
('poster', poster),
('expiry', duration),
('paste', 'Send')]
data = urllib.urlencode(params)
print('Uploading ...')
try:
req = urllib2.Request(URL, data)
response = urllib2.urlopen(req)
http_response_code = response.getcode()
if http_response_code == 200:
pasteurl = response.geturl()
if pasteurl == URL:
if "Query failure: Data too long for column" in response.readline():
print('ERROR. Request too large. Limit is 64KB.')
else:
print('ERROR. Unknown error')
else:
print(pasteurl)
else:
print('Could not upload the file, '
'HTTP Response Code %s' % (http_response_code))
except urllib2.URLError:
print('ERROR. Could not connect to pastebin.mozilla.org.')
return 1
return 0
@Command('pastebin', category='misc', conditions=[REMOVED])
def pastebin(self):
pass
def mozregression_import():