function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def testSourceApplyMacros2(self):
"""
Test applymacros
"""
recipestr1 = """ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def cleanup(r, builddir, destdir):
pass | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
# avoid cleanup
r.macros.sourcemacros = 'source-apply-macros'
r.addSource('myfile', contents="%(sourcemacros)s %(destdir)s",
macros=True)
r.macros.a = 'XXX'
r.macros.b = 'YYY'
r.macros.c = 'ZZZ'
... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testPatchFilter(self):
recipestr = """ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
# avoid cleanup
r.addSource('unpatched1')
r.addSource('unpatched2')
r.addPatch('patchToFilter.patch') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
# avoid cleanup
r.addSource('unpatched1')
r.addSource('unpatched2')
r.addPatch('patchToFilter.patch', filter='sed s/Oops// |cat | cat') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testAction(self):
recipestr1 = """ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def cleanup(r, builddir, destdir):
pass | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def findInFile(self, filename, key):
f = open(filename)
contents = f.read()
return contents.find(key) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addSource('dc_client.init', rpm='distcache-1.4.5-2.src.rpm')
r.Run('test -x dc_client.init')
# get rid of "cowardlily refusing" message
r.Create('/foo') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testAutoMainDir(self):
"""
Test mainDir automagic guessing.
"""
recipestr1 = """ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
# asdf.tar.gz contains asdf/fdsa and bam, not test-1/fdsa
r.addArchive('asdf.tar.gz')
# the next line will only work if mainDir was auto-set to asdf
r.Install('fdsa', '/') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
# asdf.tar.gz contains asdf/fdsa and bam, not test-1/fdsa
r.addArchive('asdf.tar.gz', dir='blah')
# the next line will only work if mainDir was auto-set to blah
r.Install('asdf/fdsa', '/') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
# foo-1.0.tar.gz has foo-1.0/a and blah/b
r.addArchive('foo-1.0.tar.gz')
r.Install('a', '/') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
# foo-1.0.tar.gz has foo-1.0/a and blah/b
r.addArchive('foo-1.0&;.tar.gz')
r.Install('a', '/') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testAutoMainDirGuessFailure(self):
recipestr = """ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
# foo-1.0.tar.gz has foo-1.0/a and blah/b
r.addSource('macros')
r.addArchive('distcc-2.9.tar.bz2') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testSourceMagic(self):
d = tempfile.mkdtemp()
try:
# copy setup.tar.gz to a file without .gz extension
shutil.copyfile(resources.get_archive() + '/asdf.tar.gz',
d + '/asdf')
# look in our new source directory for sources
sel... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addArchive('tmpwatch-2.9.0.tar.gz', rpm='tmpwatch-2.9.0-2.src.rpm')
r.addPatch('unrelated.patch') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testAddGoodPatch(self):
recipestr1 = """\ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addArchive('tmpwatch-2.9.0.tar.gz', rpm='tmpwatch-2.9.0-2.src.rpm')
r.addPatch('tmpwatch.fakebug.patch') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testAddGoodLevel0Patch(self):
recipestr1 = """\ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addArchive('tmpwatch-2.9.0.tar.gz', rpm='tmpwatch-2.9.0-2.src.rpm')
r.addPatch('tmpwatch.fakebug.level0.patch') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testAddGoodButRejectedPatch(self):
recipestr1 = """\ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addArchive('tmpwatch-2.9.0.tar.gz', rpm='tmpwatch-2.9.0-2.src.rpm')
r.addPatch('tmpwatch.fakebug.rej.patch') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testAddPartiallyApplicablePatch(self):
# patch partially applies at level one and completely
# applies at level 2.
recipestr1 = """\ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
contents = '\\n'.join(str(x) for x in range(1, 21)) + '\\n'
r.addSource('foo', contents=contents)
r.addSource('bar', contents=contents)
r.addAction('mkdir subdir; cp foo subdir/; touch subdir/bar')
r.addPatch('partial.patch') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testPatchSameFileTwiceInOnePatch(self):
# CNY-2142
recipestr1 = """\ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
contents = '\\n'.join(str(x) for x in range(1, 11)) + '\\n'
r.addSource('foo', contents=contents)
r.addPatch('patches/foo.patch') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testLargePatch(self):
# Test a patch that's large enough to cause our patch pipe
# to be full - this "patch" would hang if we didn't have good
# pipe handling. Done correctly, it just fails.
recipestr1 = """\ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addArchive('tmpwatch-2.9.0.tar.gz', rpm = 'tmpwatch-2.9.0-2.src.rpm')
r.addPatch('tmpwatch-2.9.0.tar.gz', rpm = 'tmpwatch-2.9.0-2.src.rpm') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testMissingPatchProgram(self):
recipestr = """\ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addPatch('tmpwatch.fakebug.patch', patchName='noSuchPatchProgram') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testTarPermissions(self):
r = policytest.DummyRecipe(self.cfg)
os.mkdir('/'.join((r.macros.builddir, r.theMainDir)))
# add an archive that has a file with group write permissions
a = source.Archive(r, 'group-write.tar.gz', dir='/')
a.doAction()
sb = os.stat(r.macros.d... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testBzipDeb(self):
r = policytest.DummyRecipe(self.cfg)
os.mkdir('/'.join((r.macros.builddir, r.theMainDir)))
# add an archive that has a file with group write permissions
a = source.Archive(r, 'test.deb', dir='/')
a.doAction()
self.assertTrue(os.path.isfile(r.macros.... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testLZMADeb(self):
r = policytest.DummyRecipe(self.cfg)
os.mkdir('/'.join((r.macros.builddir, r.theMainDir)))
a = source.Archive(r, 'testlzma.deb', dir='/')
a.doAction()
self.assertTrue(os.path.isfile(r.macros.destdir + '/testme')) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testEmptyDeb(self):
r = policytest.DummyRecipe(self.cfg)
os.mkdir('/'.join((r.macros.builddir, r.theMainDir)))
# add an archive that has a file with group write permissions
a = source.Archive(r, 'testempty.deb', dir='/')
self.assertRaises(source.SourceError, a.doAction) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addArchive('allperms.tar', dir = '/tar',
preserveOwnership = True,
preserveSetid = True,
preserveDirectories = True)
r.ExcludeDirectories(exceptions = [ '.*/foo' ] ) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testOwnershipRetention(self):
recipestr = """ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addArchive('ownerships.tar', dir = '/tar',
preserveOwnership = True) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addArchive('ownerships.tar', preserveOwnership = True) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addArchive('rrcd.iso', preserveOwnership = True, dir = '/') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addArchive('ownerships.zip', preserveOwnership = True, dir = '/') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testSourceLzop(self):
recipestr = """ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addArchive('foo.tar.lzo', dir='/') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testBadaddSource(self):
recipestr=""" | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addSource('http://foo.bar.com/directory/', dest='/mumble/') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testAddSourceDir(self):
recipeStr = """ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addSource('test', sourceDir = '')"""
class Stop(Exception):
pass
def mockDoDownload(x):
f = x._findSource(x.httpHeaders)
self.assertEquals(f, os.path.join(x.builddir,
x.recipe.macros.maindir,
... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addArchive('tmpwatch-2.9.0.tar.gz', rpm='tmpwatch-2.9.0-2.src.rpm')
r.addSource('mkinitrd.spec', rpm='rpm-with-bzip-5.0.29-1.src.rpm')
r.addArchive('rpm-with-bzip-5.0.29-1.i386.rpm')
# add patch file so it exists in builddir
r.addArchive('tmpwatch.fakebug.patch.t... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addArchive('tmpwatch-2.9.0.tar.gz', rpm='tmpwatch-2.9.0-2.src.rpm')
r.addSource('mkinitrd.spec', rpm='rpm-with-bzip-5.0.29-1.src.rpm')
r.addArchive('rpm-with-bzip-5.0.29-1.i386.rpm')
# add patch file so it exists in builddir
r.addArchive('tmpwatch.fakebug.patch.t... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
# test applying a patch using globs without sourceDir. this will fail
r.addPatch('tmpwatch.fakebug.*')"""
# globs for addPatch are only used if soruceDir is defined.
try:
self.buildRecipe(recipestr, "TestSource")
except OSError, e:
if e.errn... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def __init__(x):
pass | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def doFile(x, path):
self.orderedCalls.append(path) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _getHTTPServer(self, logFile):
class FileHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
count = 0
def log_message(slf, *args, **kw):
file(logFile, "a").write("%s\n" % slf.path)
def do_GET(slf):
if slf.path.endswith('/count'):
... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addArchive([
"http://localhost:%(port)s/bad/",
"http://localhost:%(port)s/good/",
], dir="/usr/share/foo/") | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addSource([
"http://localhost:%(port)s/bad/foo-1.99.tar.gz",
"http://localhost:%(port)s/good/",
], dir="/usr/share/foo/") | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testAddArchivePassword(self):
recipestr = """ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addSource("http://foo:bar@localhost:%(port)s/good/count",
dest='/foo') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testMultiURLMirror(self):
recipestr = """ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addArchive([
"mirror://alif/%(rest)s",
"mirror://ba/%(rest)s",
], dir="/usr/share/foo/") | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testMirrorLookaside(self):
# CNY-2696
# There was a bug in the way the mirror name was computed
recipestr = """ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
r.addArchive("mirror://alif/blah/", keyid = 'DEADBEEF',
dir="/usr/share/foo/") | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testRpmLookaside(self):
recipeStr = """ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
# prove that the sourcedir level foo isn't even looked up if rpm is
# specified
r.addArchive('foo-1.0-1.src.rpm')
r.addSource('foo', dir = '/bar', rpm = 'foo-1.0-1.src.rpm') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testRpmLookaside2(self):
recipeStr = """ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
# now prove that both can be used at the same time
r.addArchive('foo-1.0-1.src.rpm')
# add the sorucedir foo first to "poison" the lookaside
r.addSource('foo', dir = '/baz')
r.addSource('foo', dir = '/bar', rpm = 'foo-1.0-1.src.rpm') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testRpmLookaside3(self):
recipeStr = """ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
# now prove that two rpm's can have distinct contents at once
r.addArchive('foo-1.0-1.src.rpm')
r.addArchive('foo-1.0-2.src.rpm')
r.addSource('foo.spec', dir = '/1', rpm = 'foo-1.0-1.src.rpm')
r.addSource('foo.spec', dir = '/2', rpm = 'foo-1.0-2.src.rpm') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testRpmLookaside4(self):
recipeStr = """ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
# ensure missing files within the rpm respond sensibly
r.addArchive('foo-1.0-1.src.rpm')
r.addSource('notfound', dir = '/bar', rpm = 'foo-1.0-1.src.rpm') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def testRepositoryCookNoDownload(self):
# CNY-3221, RMK-995
# We want to make sure that repositoy cooks don't re-download the
# content (nor do they try to download wrong guesses)
recipestr = """ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
# ensure missing files within the rpm respond sensibly
r.addArchive('http://localhost:%(port)s/good/', dir = "/usr") | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def test_extractFilesFromXzRPM(self):
if not os.path.exists('/usr/bin/xz'):
raise testhelp.SkipTestException('The /usr/bin/xz binary is required to run this test')
recipestr = """ | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setup(r):
# ensure missing files within the rpm respond sensibly
r.addArchive('popt-1.13-6.fc12.i686.rpm', dir = '/') | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def process(self, response):
soup = bs(response.m_response.content, 'lxml')
province_div_list = soup.select('div.city-list div.cap-city > div.fn-clear')
for province_div in province_div_list:
province_name = province_div.select('span.capital a')[0].text
city_list = provin... | DarkSand/Sasila | [
294,
75,
294,
2,
1484044688
] |
def process_page_1(self, response):
brand_list = list(json.loads(response.m_response.content.decode('gb2312')))
for brand in brand_list:
brand_dict = dict(brand)
brand_name = brand_dict['name']
url = response.nice_join(brand_dict['url']) + '/'
request = Re... | DarkSand/Sasila | [
294,
75,
294,
2,
1484044688
] |
def process_page_2(self, response):
soup = bs(response.m_response.content, 'lxml')
cars_line_list = soup.select('div#series div.content-area dl.model-list dd a')
for cars_line in cars_line_list:
cars_line_name = cars_line.text
url = 'http://www.che168.com' + cars_line['hr... | DarkSand/Sasila | [
294,
75,
294,
2,
1484044688
] |
def process_page_3(self, response):
soup = bs(response.m_response.content, 'lxml')
car_info_list = soup.select('div#a2 ul#viewlist_ul li a.carinfo')
for car_info in car_info_list:
url = 'http://www.che168.com' + car_info['href']
request = Request(url=url, priority=4, call... | DarkSand/Sasila | [
294,
75,
294,
2,
1484044688
] |
def process_page_4(self, response):
soup = bs(response.m_response.content, 'lxml')
# <html><head><title>Object moved</title></head><body>
# <h2>Object moved to <a href="/CarDetail/wrong.aspx?errorcode=5&backurl=/&infoid=21415515">here</a>.</h2>
# </body></html>
if len(sou... | DarkSand/Sasila | [
294,
75,
294,
2,
1484044688
] |
def __init__(self, handler, request, protocols):
self._handler = handler
self._deferred = None
self.device_id = request.id
self._name = request.name
self._url = request.url
self._crc = request.crc
self._version = request.image_version
self._local = request... | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def create(handler, request, supported_protocols):
"""
Create and start a new image download
:param handler: (AdtranDeviceHandler) Device download is for
:param request: (ImageDownload) Request
:param supported_protocols: (list) download methods allowed (http, tftp, ...)
... | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def name(self):
return self._name | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def download_state(self):
return self._download_state | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def failure_reason(self):
return self._failure_reason | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def image_state(self):
return self._image_state | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def additional_info(self):
return self._additional_info | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def downloaded_bytes(self):
return self._downloaded_octets | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def profile_name(self):
return self._server_profile_name | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def start_download(self):
import uuid
log.info('download-start', name=self.name)
if not self.parse_url():
self._download_failed()
returnValue('failed url parsing')
self._download_state = ImageDownload.DOWNLOAD_STARTED
self._failure_reason = ImageDownload.... | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def server_profile_xml(self):
assert self._scheme in ['http', 'https', 'ftp', 'sftp', 'tftp'], 'Invalid protocol'
xml = """
<file-servers xmlns="http://www.adtran.com/ns/yang/adtran-file-servers">
<profiles>
<profile>"""
xml += '<name>{}</name>'.... | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def download_job_xml(self):
# TODO: May want to support notifications
# TODO: Not sure about this name for the entity
entity = 'main 0'
xml = """
<maintenance-jobs xmlns="http://www.adtran.com/ns/yang/adtran-maintenance-jobs" xmlns:adtn-phys-sw-mnt="http://www.adtran.com/ns... | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def download_status_xml(self):
xml = """
<filter>
<maintenance-jobs-state xmlns="http://www.adtran.com/ns/yang/adtran-maintenance-jobs">
<maintenance-job>
<name>{}</name>
</maintenance-job>
</maintenance-jobs-s... | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def delete_server_profile_xml(self):
xml = """
<file-servers xmlns="http://www.adtran.com/ns/yang/adtran-file-servers">
<profiles operation="delete">
<profile>
<name>{}</name>
</profile>
</profiles>
</file-servers>
""".format(sel... | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def delete_download_job_xml(self):
xml = """
<maintenance-jobs xmlns="http://www.adtran.com/ns/yang/adtran-maintenance-jobs">
<maintenance-job operation="delete">>
<name>{}</name>
</maintenance-job>
</maintenance-jobs>
""".format(self._download_job_name)
... | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def monitor_download_status(self):
log.debug('monitor-download', name=self.name)
try:
results = yield self._handler.netconf_client.get(self.download_status_xml)
result_dict = xmltodict.parse(results.data_xml)
entries = result_dict['data']['maintenance-jobs-state']['m... | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def _download_complete(self):
log.info('download-completed', name=self.name)
self._cancel_deferred()
self._download_state = ImageDownload.DOWNLOAD_SUCCEEDED
self._downloaded_octets = 123456
self._failure_reason = ImageDownload.NO_ERROR
reactor.callLater(0, self._cleanup... | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def _cleanup_server_profile(self, retries, attempt=1):
log.info('cleanup-server', name=self.name,
profile=self._server_profile_name,
attempt=attempt, remaining=retries)
if self._server_profile_name is not None:
try:
profile = self.delete_ser... | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def _cleanup_download_job(self, retries, attempt=1):
log.info('cleanup-download', name=self.name,
profile=self._download_job_name,
attempt=attempt, remaining=retries)
if self._download_job_name is not None:
try:
job = self.delete_download_jo... | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
def activate_image(self):
log.info('download-activate', name=self.name)
if self._download_state == ImageDownload.DOWNLOAD_SUCCEEDED:
pass # TODO: Implement
self._image_state = ImageDownload.IMAGE_ACTIVE
returnValue('TODO: Implement this') | opencord/voltha | [
73,
117,
73,
17,
1484694318
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.