Skip to content

Commit

Permalink
Issue Metacello#406: bonus cleanup of .err files created downloading …
Browse files Browse the repository at this point in the history
…github tag files ... only an issue for Squeak and GemStone
  • Loading branch information
dalehenrich committed Jul 29, 2016
1 parent f3257d7 commit 494fe28
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 32 deletions.
Expand Up @@ -26,4 +26,5 @@ downloadBasicFile: url to: outputFileName username: username pass: pass
proc ifNil: [ OSProcess noAccessorAvailable ].
[ proc isRunning ] whileTrue: [ (Delay forMilliseconds: 100) wait ].
out close.
err close.
err close.
^ errorFileName
@@ -1,15 +1,28 @@
github/bitbucket support
downloadJSON: url username: username pass: pass
"return result of parsing JSON downloaded from url. username:pass may be nil, but calls will be subject to severe rate limits."
"return result of parsing JSON downloaded from url. username:pass may be nil, but calls will be subject to severe rate limits."

| jsonFileName jsonFile |
jsonFileName := self tempFileFor: 'tags-' , self processPID suffix: 'json'.
self
downloadBasicFile: url
to: jsonFileName
username: username
pass: pass.
jsonFile := self fileHandleOn: jsonFileName.
jsonFile containingDirectory
readOnlyFileNamed: jsonFile localName
do: [ :fileStream | ^ MCFileTreeJsonParser parseStream: fileStream ]
| jsonFileName jsonFile errorFileName |
jsonFileName := self
tempFileFor: 'tags-' , self processPID
suffix: 'json'.
errorFileName := self
downloadBasicFile: url
to: jsonFileName
username: username
pass: pass.
[ jsonFile := self fileHandleOn: jsonFileName.
jsonFile containingDirectory
readOnlyFileNamed: jsonFile localName
do: [ :fileStream |
| result |
result := MCFileTreeJsonParser
parseStream: fileStream self
deleteFileNamed: errorFileName.
^ result ] ]
on: Error
do: [ :ex |
self
error:
'Error during download (' , ex description , ') please check the file '
, errorFileName printString , ' for error message.' ]
@@ -1,10 +1,24 @@
github support
downloadZipArchive: url to: outputFileName
"download zip archive from <url> into <outputFileName>"
"download zip archive from <url> into <outputFileName>"

| archive zipfile |
self downloadBasicFile: url to: outputFileName username: nil pass: nil.
archive := ZipArchive new.
zipfile := self fileHandleOn: outputFileName.
zipfile containingDirectory readOnlyFileNamed: zipfile localName do: [ :fileStream | archive readFrom: fileStream ].
^ archive
| archive zipfile errorFileName |
errorFileName := self
downloadBasicFile: url
to: outputFileName
username: nil
pass: nil.
archive := ZipArchive new.
zipfile := self fileHandleOn: outputFileName.
zipfile containingDirectory
readOnlyFileNamed: zipfile localName
do: [ :fileStream |
[ archive readFrom: fileStream ]
on: Error
do: [ :ex |
self
error:
'Error during download (' , ex description , ') please check the file '
, errorFileName printString , ' for error message.' ] ].
self deleteFileNamed: errorFileName.
^ archive
Expand Up @@ -2,9 +2,10 @@ github support
extractRepositoryFrom: zipFile to: directory
"unzip <zipFile> into <directory>"

| out err proc errorMessage |
out := FileStream forceNewFileNamed: '/tmp/zip.out'.
err := FileStream forceNewFileNamed: '/tmp/zip.err'.
| out err proc errorMessage errorFileName |
errorFileName := self downloadErrorFileNameFor: zipFile.
out := FileStream forceNewFileNamed: '/dev/zip.out'.
err := FileStream forceNewFileNamed: errorFileName.
errorMessage := ''.
[
proc := OSProcess thisOSProcess
Expand All @@ -22,11 +23,11 @@ extractRepositoryFrom: zipFile to: directory
out close.
err close ].
FileStream
fileNamed: '/tmp/zip.err'
fileNamed: errorFileName
do: [ :fileStream |
(errorMessage := fileStream contentsOfEntireFile) notEmpty
ifTrue: [ self error: 'unzip failure: ' , errorMessage printString ]
ifFalse: [
(self fileHandleOn: '/tmp')
deleteFileNamed: zipFile;
deleteFileNamed: (self downloadErrorFileNameFor: zipFile) ] ]
deleteFileNamed: errorFileName ] ]
Expand Up @@ -9,11 +9,9 @@
"copyClass:as:inCategory:" : "CamilleTeruel 11/21/2013 12:43",
"createRepository:" : "ChristopheDemarey 4/30/2013 09:24",
"defaultPlatformAttributes" : "ChristopheDemarey 4/30/2013 09:24",
"downloadBasicFile:to:username:pass:" : "ChristopheDemarey 8/7/2015 15:33",
"downloadFile:to:" : "CamilloBruni 10/15/2013 21:35",
"downloadJSON:username:pass:" : "dkh 8/4/2015 15:53:33",
"downloadZipArchive:to:" : "ChristopheDemarey 08/29/2014 05:37:06",
"extractRepositoryFrom:to:" : "MarcusDenker 10/16/2013 10:39",
"downloadBasicFile:to:username:pass:" : "TravisCI 7/28/2016 16:39",
"downloadJSON:username:pass:" : "TravisCI 7/28/2016 17:02",
"downloadZipArchive:to:" : "TravisCI 7/28/2016 17:00",
"extractRepositoryFrom:to:" : "TravisCI 7/28/2016 16:54",
"extractTypeFromDescription:" : "ChristopheDemarey 4/30/2013 09:25",
"tempFileFor:suffix:" : "ChristopheDemarey 7/15/2014 16:13",
"timestamp" : "ChristopheDemarey 4/30/2013 09:25" } }
@@ -1 +1 @@
(name 'Metacello-PharoCommonPlatform-ChristopheDemarey.16' message 'merged by GitFileTree-MergeDriver' id 'ca1695ae-ba3b-48de-b811-c92c442e9c1d' date '10 August 2015' time '11:43:12.581088 am' author 'ChristopheDemarey' ancestors ((name 'Metacello-PharoCommonPlatform-ChristopheDemarey.15' message 'Temporary variables not read AND writtenChecks that all temporary variables are both read and written.MetacelloPharoCommonPlatform>>#downloadBasicFile:to:username:pass:' id '8b35c1c4-46c0-4842-82ac-23f1de761737' date '7 August 2015' time '3:37:51.323758 pm' author 'ChristopheDemarey' ancestors ((name 'Metacello-PharoCommonPlatform-dkh.14' message 'merged by GitFileTree-MergeDriver' id '22113d56-db7a-409e-a572-5298de908331' date '4 August 2015' time '3:53:33.874158 pm' author 'dkh' ancestors ((name 'Metacello-PharoCommonPlatform-ChristopheDemarey.13' message 'Issue #277: rename platform downloadFile:to: to downloadZipArchive:to:' id '9e60a324-6db0-4601-8383-aaa098887710' date '14 October 2014' time '5:18:48 pm' author 'dkh' ancestors ((name 'Metacello-PharoCommonPlatform-ChristopheDemarey.12' message 'Removes MetacelloPharo30Platform>>tempFileFor:suffix: ' id 'b3eaf606-f93c-476b-908a-d5b5fa3bde0d' date '29 August 2014' time '5:37:06 am' author 'ChristopheDemarey' ancestors ((name 'Metacello-PharoCommonPlatform-ChristopheDemarey.11' message 'fix https://pharo.fogbugz.com/f/cases/13557/Github-zip-download-doesn-t-check-for-the-existence-of-file-with-the-same-name' id '369f0f46-f169-42ee-b81e-e4710f5089f2' date '15 July 2014' time '4:26:25 am' author 'ChristopheDemarey' ancestors ((name 'Metacello-PharoCommonPlatform-MarcusDenker.10' message '12372 remove all direct references to Compiler https://pharo.fogbugz.com/f/cases/12372 12357 Failing test: #testCanUnderstand https://pharo.fogbugz.com/f/cases/12357 ' id '5b41af5b-1b4b-4b2c-b14b-c01aaec71a0c' date '8 December 2013' time '12:39:42 pm' author 'MarcusDenker' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())(name 'Metacello-PharoCommonPlatform-ChristopheDemarey.13' message 'Add an accessor for the compiler. Use asClass instead of direct references to OSProcess or FileDirectory.' id '2319197d-0089-40b6-8e99-725abab8d011' date '4 August 2015' time '11:04:53.135409 am' author 'ChristopheDemarey' ancestors ((name 'Metacello-PharoCommonPlatform-StephaneDucasse.12' message '13560 remove DSA seed generation from sound input https://pharo.fogbugz.com/f/cases/1356013555 IconicListItem should be packaged in Widgets-Basic https://pharo.fogbugz.com/f/cases/1355513556 ImagePreviewMorph could be packaged close to AlphaImageMorph https://pharo.fogbugz.com/f/cases/1355613559 ControlButtonMorph and PluggableButtonMorph could be moved to Widgets-Base https://pharo.fogbugz.com/f/cases/1355913557 Github zip download does not check for the existence of file with the same name https://pharo.fogbugz.com/f/cases/13557' id 'b2ad2e31-ec1b-4f30-9b1a-2a978632793a' date '15 July 2014' time '8:50:51.662016 pm' author 'StephaneDucasse' ancestors ((name 'Metacello-PharoCommonPlatform-ChristopheDemarey.11' message 'Fix https://pharo.fogbugz.com/f/cases/13557/Github-zip-download-doesn-t-check-for-the-existence-of-file-with-the-same-name' id '8b01ad3c-59f0-429a-9333-861eb9c2e60c' date '15 July 2014' time '4:21:46.591047 pm' author 'ChristopheDemarey' ancestors ((id '5b41af5b-1b4b-4b2c-b14b-c01aaec71a0c')) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())(id '9e60a324-6db0-4601-8383-aaa098887710')) stepChildren ())
(name 'Metacello-PharoCommonPlatform-TravisCI.17' message 'Issue #406: bonus cleanup of .err files created downloading github tag files ... only an issue for Squeak and GemStone' id 'aa9c7611-40d5-4f8b-b54d-65f9a80a1951' date '28 July 2016' time '5:23:21.835141 pm' author 'TravisCI' ancestors ((name 'Metacello-PharoCommonPlatform-ChristopheDemarey.16' message 'merged by GitFileTree-MergeDriver' id 'ca1695ae-ba3b-48de-b811-c92c442e9c1d' date '10 August 2015' time '11:43:12.581088 am' author 'ChristopheDemarey' ancestors ((name 'Metacello-PharoCommonPlatform-ChristopheDemarey.15' message 'Temporary variables not read AND writtenChecks that all temporary variables are both read and written.MetacelloPharoCommonPlatform>>#downloadBasicFile:to:username:pass:' id '8b35c1c4-46c0-4842-82ac-23f1de761737' date '7 August 2015' time '3:37:51.323758 pm' author 'ChristopheDemarey' ancestors ((name 'Metacello-PharoCommonPlatform-dkh.14' message 'merged by GitFileTree-MergeDriver' id '22113d56-db7a-409e-a572-5298de908331' date '4 August 2015' time '3:53:33.874158 pm' author 'dkh' ancestors ((name 'Metacello-PharoCommonPlatform-ChristopheDemarey.13' message 'Issue #277: rename platform downloadFile:to: to downloadZipArchive:to:' id '9e60a324-6db0-4601-8383-aaa098887710' date '14 October 2014' time '5:18:48 pm' author 'dkh' ancestors ((name 'Metacello-PharoCommonPlatform-ChristopheDemarey.12' message 'Removes MetacelloPharo30Platform>>tempFileFor:suffix: ' id 'b3eaf606-f93c-476b-908a-d5b5fa3bde0d' date '29 August 2014' time '5:37:06 am' author 'ChristopheDemarey' ancestors ((name 'Metacello-PharoCommonPlatform-ChristopheDemarey.11' message 'fix https://pharo.fogbugz.com/f/cases/13557/Github-zip-download-doesn-t-check-for-the-existence-of-file-with-the-same-name' id '369f0f46-f169-42ee-b81e-e4710f5089f2' date '15 July 2014' time '4:26:25 am' author 'ChristopheDemarey' ancestors ((name 'Metacello-PharoCommonPlatform-MarcusDenker.10' message '12372 remove all direct references to Compiler https://pharo.fogbugz.com/f/cases/12372 12357 Failing test: #testCanUnderstand https://pharo.fogbugz.com/f/cases/12357 ' id '5b41af5b-1b4b-4b2c-b14b-c01aaec71a0c' date '8 December 2013' time '12:39:42 pm' author 'MarcusDenker' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())(name 'Metacello-PharoCommonPlatform-ChristopheDemarey.13' message 'Add an accessor for the compiler. Use asClass instead of direct references to OSProcess or FileDirectory.' id '2319197d-0089-40b6-8e99-725abab8d011' date '4 August 2015' time '11:04:53.135409 am' author 'ChristopheDemarey' ancestors ((name 'Metacello-PharoCommonPlatform-StephaneDucasse.12' message '13560 remove DSA seed generation from sound input https://pharo.fogbugz.com/f/cases/1356013555 IconicListItem should be packaged in Widgets-Basic https://pharo.fogbugz.com/f/cases/1355513556 ImagePreviewMorph could be packaged close to AlphaImageMorph https://pharo.fogbugz.com/f/cases/1355613559 ControlButtonMorph and PluggableButtonMorph could be moved to Widgets-Base https://pharo.fogbugz.com/f/cases/1355913557 Github zip download does not check for the existence of file with the same name https://pharo.fogbugz.com/f/cases/13557' id 'b2ad2e31-ec1b-4f30-9b1a-2a978632793a' date '15 July 2014' time '8:50:51.662016 pm' author 'StephaneDucasse' ancestors ((name 'Metacello-PharoCommonPlatform-ChristopheDemarey.11' message 'Fix https://pharo.fogbugz.com/f/cases/13557/Github-zip-download-doesn-t-check-for-the-existence-of-file-with-the-same-name' id '8b01ad3c-59f0-429a-9333-861eb9c2e60c' date '15 July 2014' time '4:21:46.591047 pm' author 'ChristopheDemarey' ancestors ((id '5b41af5b-1b4b-4b2c-b14b-c01aaec71a0c')) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())(id '9e60a324-6db0-4601-8383-aaa098887710')) stepChildren ())) stepChildren ())
Expand Down

0 comments on commit 494fe28

Please sign in to comment.