Skip to content

Commit

Permalink
replace temporaryfile with stringio
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcarter committed Jan 29, 2017
1 parent 056296f commit 3a303c1
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions cumulusci/salesforce_api/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# import dateutil.parser
import httplib
import re
from tempfile import TemporaryFile
import time
from xml.dom.minidom import parseString
from zipfile import ZipFile
import StringIO

import requests

Expand Down Expand Up @@ -277,9 +277,8 @@ def _process_response(self, response):
zipstr = zipstr[0].firstChild.nodeValue
else:
return self.packages
zipfp = TemporaryFile()
zipfp.write(base64.b64decode(zipstr))
zipfile = ZipFile(zipfp, 'r')
zipstringio = StringIO.StringIO(base64.b64decode(zipstr))
zipfile = ZipFile(zipstringio, 'r')
return zipfile

class ApiRetrieveInstalledPackages(BaseMetadataApiCall):
Expand All @@ -302,9 +301,8 @@ def _process_response(self, response):
zipstr = zipstr[0].firstChild.nodeValue
else:
return self.packages
zipfp = TemporaryFile()
zipfp.write(base64.b64decode(zipstr))
zipfile = ZipFile(zipfp, 'r')
zipstringio = StringIO.StringIO(base64.b64decode(zipstr))
zipfile = ZipFile(zipstringio, 'r')
packages = {}
# Loop through all files in the zip skipping anything other than
# InstalledPackages
Expand Down Expand Up @@ -348,9 +346,8 @@ def _process_response(self, response):
zipstr = zipstr[0].firstChild.nodeValue
else:
return self.packages
zipfp = TemporaryFile()
zipfp.write(base64.b64decode(zipstr))
zipfile = ZipFile(zipfp, 'r')
zipstringio = StringIO.StringIO(base64.b64decode(zipstr))
zipfile = ZipFile(zipstringio, 'r')
return zipfile


Expand Down Expand Up @@ -504,8 +501,7 @@ def __init__(self, task, version, purge_on_delete=False):
except:
raise ValueError('Failed to fetch zip from %s' %
self.version.zip_url)
zipfp = TemporaryFile()
zipfp.write(zip_resp.content)
zipfp = StringIO.StringIO(zip_resp.content)
zipfile = ZipFile(zipfp, 'r')
if not self.version.subfolder and not self.version.repo_url:
zipfile.close()
Expand Down

0 comments on commit 3a303c1

Please sign in to comment.