From 494fe2811a7688a9cda700c96edeadbe4d23ba7e Mon Sep 17 00:00:00 2001 From: Dale Henrichs Date: Thu, 28 Jul 2016 17:24:08 -0700 Subject: [PATCH] Issue #406: bonus cleanup of .err files created downloading github tag files ... only an issue for Squeak and GemStone --- .../downloadBasicFile.to.username.pass..st | 3 +- .../instance/downloadJSON.username.pass..st | 37 +++++++++++++------ .../instance/downloadZipArchive.to..st | 28 ++++++++++---- .../instance/extractRepositoryFrom.to..st | 11 +++--- .../methodProperties.json | 10 ++--- .../monticello.meta/version | 2 +- 6 files changed, 59 insertions(+), 32 deletions(-) diff --git a/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/instance/downloadBasicFile.to.username.pass..st b/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/instance/downloadBasicFile.to.username.pass..st index cfa0a8494..117fbafda 100644 --- a/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/instance/downloadBasicFile.to.username.pass..st +++ b/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/instance/downloadBasicFile.to.username.pass..st @@ -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. \ No newline at end of file + err close. + ^ errorFileName \ No newline at end of file diff --git a/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/instance/downloadJSON.username.pass..st b/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/instance/downloadJSON.username.pass..st index df1bbfa30..da63d3a74 100644 --- a/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/instance/downloadJSON.username.pass..st +++ b/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/instance/downloadJSON.username.pass..st @@ -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.' ] \ No newline at end of file diff --git a/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/instance/downloadZipArchive.to..st b/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/instance/downloadZipArchive.to..st index 8419e60ee..ebf1cb339 100644 --- a/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/instance/downloadZipArchive.to..st +++ b/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/instance/downloadZipArchive.to..st @@ -1,10 +1,24 @@ github support downloadZipArchive: url to: outputFileName - "download zip archive from into " + "download zip archive from into " - | 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 \ No newline at end of file diff --git a/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/instance/extractRepositoryFrom.to..st b/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/instance/extractRepositoryFrom.to..st index a9fce36fc..34d80247e 100644 --- a/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/instance/extractRepositoryFrom.to..st +++ b/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/instance/extractRepositoryFrom.to..st @@ -2,9 +2,10 @@ github support extractRepositoryFrom: zipFile to: directory "unzip into " - | 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 @@ -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 ] ] diff --git a/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/methodProperties.json b/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/methodProperties.json index ffa7babda..6b53bbcfd 100644 --- a/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/methodProperties.json +++ b/repository/Metacello-PharoCommonPlatform.package/MetacelloPharoCommonPlatform.class/methodProperties.json @@ -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" } } diff --git a/repository/Metacello-PharoCommonPlatform.package/monticello.meta/version b/repository/Metacello-PharoCommonPlatform.package/monticello.meta/version index 0d57f02e8..6947bd34b 100644 --- a/repository/Metacello-PharoCommonPlatform.package/monticello.meta/version +++ b/repository/Metacello-PharoCommonPlatform.package/monticello.meta/version @@ -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 written Checks 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/13560 13555 IconicListItem should be packaged in Widgets-Basic https://pharo.fogbugz.com/f/cases/13555 13556 ImagePreviewMorph could be packaged close to AlphaImageMorph https://pharo.fogbugz.com/f/cases/13556 13559 ControlButtonMorph and PluggableButtonMorph could be moved to Widgets-Base https://pharo.fogbugz.com/f/cases/13559 13557 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 ()) \ No newline at end of file +(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 written Checks 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/13560 13555 IconicListItem should be packaged in Widgets-Basic https://pharo.fogbugz.com/f/cases/13555 13556 ImagePreviewMorph could be packaged close to AlphaImageMorph https://pharo.fogbugz.com/f/cases/13556 13559 ControlButtonMorph and PluggableButtonMorph could be moved to Widgets-Base https://pharo.fogbugz.com/f/cases/13559 13557 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 ()) \ No newline at end of file