I'm trying to download multiple files, but for some reason, it only downloads one file.
My code:
for (var fl = 0; fl < fileurls.length; fl++){
var fname = fileurls[fl].substr(fileurls[fl].lastIndexOf('/')+1);
var file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, fname);
if(file.exists()) {
dlurls.push(fname);
Ti.API.info('File exists, adding: ' + fname)
}
if(!file.exists()) {
Ti.API.info('File does not exist, downloading: ' + fname)
modalview.show();
ind.show();
c.open('GET',fileurls[fl]);
ind.message = 'Downloading: ' + fname;
c.file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, fname);
c.onload = function(e)
{
dlurls.push(fname);
};
c.send();
}
Ti.API.info('Total files: ' + fileurls.length + ' Downloaded files: ' + dlurls.length)
if (fileurls.length==dlurls.length){
modalview.hide();
ind.hide();
}
}
So the for loop parses the json, and finds all the photos that need to be downloaded.
It checks the file system to see if they exist in which case it pushes the filename to the downloaded files list. If the file does not exist, it initiates a download which when complete pushes the file to the downloaded file list.
When done if filelist is equal to downloaded file list, means all files are there.
So, it does loop through all the files, but only one download is initiated?
[INFO] : File does not exist, downloading: IMG_1643_result.JPG
[INFO] : Total files: 27 Downloaded files: 0
[INFO] : File does not exist, downloading: IMG_3883_result.JPG
[INFO] : Total files: 27 Downloaded files: 0
[INFO] : File does not exist, downloading: 32103.JPG
[ERROR] : Must set a connection to OPENED before send()
[INFO] : Total files: 27 Downloaded files: 0
[INFO] : File does not exist, downloading: 32142.JPG
[INFO] : Total files: 27 Downloaded files: 0
[INFO] : File does not exist, downloading: kale02.JPG
[ERROR] : Must set a connection to OPENED before send()
[INFO] : Total files: 27 Downloaded files: 0
[INFO] : File does not exist, downloading: 3213212.JPG
[INFO] : Total files: 27 Downloaded files: 0
[INFO] : File does not exist, downloading: 32123.JPG
[INFO] : Total files: 27 Downloaded files: 0
[INFO] : File does not exist, downloading: 32132.jpg
[ERROR] : Must set a connection to OPENED before send()
...
[INFO] : Total files: 27 Downloaded files: 1
[INFO] : ONDATASTREAM1 - PROGRESS: 1
[INFO] : ONDATASTREAM1 - PROGRESS: 0.602950394153595
[INFO] : ONDATASTREAM1 - PROGRESS: 1
[INFO] : ONDATASTREAM1 - PROGRESS: 1.6029504537582397
[INFO] : ONDATASTREAM1 - PROGRESS: 1.1585098505020142
[INFO] : ONDATASTREAM1 - PROGRESS: 2.1585099697113037
[INFO] : ONDATASTREAM1 - PROGRESS: 1
[INFO] : ONDATASTREAM1 - PROGRESS: 2.2008988857269287
[INFO] : ONDATASTREAM1 - PROGRESS: 1
[INFO] : ONDATASTREAM1 - PROGRESS: 1
[INFO] : ONDATASTREAM1 - PROGRESS: 1
[INFO] : ONDATASTREAM1 - PROGRESS: 3.8818702697753906
[INFO] : ONDATASTREAM1 - PROGRESS: 4.881870269775391
[INFO] : ONDATASTREAM1 - PROGRESS: 1
[INFO] : ONDATASTREAM1 - PROGRESS: 1
[INFO] : ONDATASTREAM1 - PROGRESS: 2.251030445098877
[INFO] : ONDATASTREAM1 - PROGRESS: 3.251030445098877
Ok, so what i did is i put the entire request in a function, and then had the oncomplete call call the function. Now it works.
Related
[INFO] : Processing JavaScript files
[INFO] : Encrypting JavaScript files: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\titanium_prep.win32.exe "com.voxcinemas.voxcinemasdev" "E:\Titanium\voxcinemastitanium\build\android\assets" "app.js" "config.js" "gcm.js" "gcm_activity.js" "icons.js" "iphone/lib/db.js" "iphone/lib/genericWindow.js" "iphone/lib/helper.js" "iphone/lib/httpClient.js" "iphone/lib/indicator.js" "iphone/lib/style.js" "iphone/lib/styleIOS7.js" "iphone/lib/views.js" "iphone/lib/viewsIOS7.js" "iphone/lib/youtube.js" "iphone/viewcontroller/applicationTabGroup.js" "iphone/viewcontroller/buyTicketsWindow.js" "iphone/viewcontroller/cardDetailsWindow.js" "iphone/viewcontroller/cinemasWindow.js" "iphone/viewcontroller/detailPageWindow.js" "iphone/viewcontroller/error.js" "iphone/viewcontroller/expDetailWindow.js" "iphone/viewcontroller/expWindow.js" "iphone/viewcontroller/favCinemasDetailsWindow.js" "iphone/viewcontroller/favCinemasWindow.js" "iphone/viewcontroller/moviesWindow.js" "iphone/viewcontroller/myAccountWindow.js" "iphone/viewcontroller/offerWindow.js" "iphone/viewcontroller/offerWindowStep2.js" "iphone/viewcontroller/paymentWindow.js" "iphone/viewcontroller/rewardsWindow.js" "iphone/viewcontroller/termsConditionsWindow.js" "iphone/viewcontroller/ticketConfirmationWindow.js" "iphone/viewcontroller/todayWindow.js" "iphone/viewcontroller/transactionHistoryWindow.js" "iphone/viewcontroller/userDetailsWindow.js" "iphone/viewcontroller/webView.js" "iphone/viewcontrollerIOS7/applicationTabGroup.js" "iphone/viewcontrollerIOS7/buyTicketsWindow.js" "iphone/viewcontrollerIOS7/cardDetailsWindow.js" "iphone/viewcontrollerIOS7/cinemasWindow.js" "iphone/viewcontrollerIOS7/detailPageWindow.js" "iphone/viewcontrollerIOS7/error.js" "iphone/viewcontrollerIOS7/expDetailWindow.js" "iphone/viewcontrollerIOS7/expWindow.js" "iphone/viewcontrollerIOS7/favCinemasDetailsWindow.js" "iphone/viewcontrollerIOS7/favCinemasWindow.js" "iphone/viewcontrollerIOS7/moviesWindow.js" "iphone/viewcontrollerIOS7/myAccountWindow.js" "iphone/viewcontrollerIOS7/offerWindow.js" "iphone/viewcontrollerIOS7/offerWindowStep2.js" "iphone/viewcontrollerIOS7/paymentWindow.js" "iphone/viewcontrollerIOS7/rewardsWindow.js" "iphone/viewcontrollerIOS7/termsConditionsWindow.js" "iphone/viewcontrollerIOS7/ticketConfirmationWindow.js" "iphone/viewcontrollerIOS7/todayWindow.js" "iphone/viewcontrollerIOS7/transactionHistoryWindow.js" "iphone/viewcontrollerIOS7/userDetailsWindow.js" "iphone/viewcontrollerIOS7/webView.js" "lib/db.js" "lib/genericWindow.js" "lib/helper.js" "lib/httpClient.js" "lib/indicator.js" "lib/style.js" "lib/views.js" "lib/youtube.js" "viewcontroller/androidHomeWindow.js" "viewcontroller/buyTicketsWindow.js" "viewcontroller/cardDetailsWindow.js" "viewcontroller/detailPageWindow.js" "viewcontroller/error.js" "viewcontroller/expDetailWindow.js" "viewcontroller/favCinemasDetailsWindow.js" "viewcontroller/favCinemasWindow.js" "viewcontroller/myAccountWindow.js" "viewcontroller/offerWindow.js" "viewcontroller/offerWindowStep2.js" "viewcontroller/paymentWindow.js" "viewcontroller/rewardsWindow.js" "viewcontroller/termsConditionsWindow.js" "viewcontroller/ticketConfirmationWindow.js" "viewcontroller/transactionHistoryWindow.js" "viewcontroller/userDetailsWindow.js" "viewcontroller/webView.js" "ti.cloud.js" "_app_props_.json"
[INFO] : Writing E:\Titanium\voxcinemastitanium\build\android\bin\assets\app.json
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-analytics.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-android.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-app.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-filesystem.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-media.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-locale.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-network.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-xml.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-utils.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-geolocation.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-accelerometer.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-contacts.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-map.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-gesture.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-calendar.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-platform.res.zip
[INFO] : Extracting module resources: C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-database.res.zip
[INFO] : No aidl files to compile, continuing
[INFO] : Generating i18n files
[INFO] : Generating E:\Titanium\voxcinemastitanium\build\android\res\values\theme.xml
[INFO] : Packaging application: C:\Users\Ramesh\AppData\Local\Android\sdk\build-tools\23.0.1\aapt.exe "package" "-f" "-m" "-J" "E:\Titanium\voxcinemastitanium\build\android\gen" "-M" "E:\Titanium\voxcinemastitanium\build\android\AndroidManifest.xml" "-A" "E:\Titanium\voxcinemastitanium\build\android\bin\assets" "-S" "E:\Titanium\voxcinemastitanium\build\android\res" "-I" "C:\Users\Ramesh\AppData\Local\Android\sdk\platforms\android-22\android.jar" "-F" "E:\Titanium\voxcinemastitanium\build\android\bin\app.ap_" "--auto-add-overlay" "--extra-packages" "ti.modules.titanium.ui:android.support.v7.appcompat:com.google.android.gms" "-S" "C:\Users\Ramesh\AppData\Local\Temp\115824-4792-1rzrtiq/res" "-S" "C:\Users\Ramesh\AppData\Local\Temp\115824-4792-ljesl8/res"
[INFO] : Building Java source files: C:\Program Files (x86)\Java\jdk1.7.0_79\bin\javac.exe "-J-Xmx256M" "-encoding" "utf8" "-bootclasspath" "C:\Users\Ramesh\AppData\Local\Android\sdk\platforms\android-22\android.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\kroll-v8.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-analytics.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\aps-analytics.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-android.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\jaxen-1.1.1.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\ti-commons-codec-1.3.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\kroll-common.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\titanium.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-app.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-ui.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\nineoldandroids-appc-2.4.0.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-filesystem.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-media.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-appcompat.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\android-support-v4.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\android-support-v7-appcompat.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-locale.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-network.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-xml.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-utils.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-geolocation.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-accelerometer.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-contacts.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-map.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-gesture.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-calendar.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-platform.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-database.jar;E:\Titanium\voxcinemastitanium\modules\android\net.iamyellow.gcmjs\0.1\gcmjs.jar;E:\Titanium\voxcinemastitanium\modules\android\net.iamyellow.gcmjs\0.1\lib\gcm.jar;C:\ProgramData\Application Data\Titanium\modules\android\ti.map\2.3.3\map.jar;C:\ProgramData\Application Data\Titanium\modules\android\ti.map\2.3.3\lib\google-play-services-base.jar;C:\ProgramData\Application Data\Titanium\modules\android\ti.map\2.3.3\lib\google-play-services-map.jar;E:\Titanium\voxcinemastitanium\modules\android\com.onecowstanding.flurry\1.1.1\flurry.jar;E:\Titanium\voxcinemastitanium\modules\android\com.onecowstanding.flurry\1.1.1\lib\FlurryAgent.jar;E:\Titanium\voxcinemastitanium\modules\android\analytics.google\3.1.0\analytics.google.jar;E:\Titanium\voxcinemastitanium\modules\android\analytics.google\3.1.0\lib\google-play-services.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\kroll-apt.jar;C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\lib\titanium-verify.jar;Manifest.class;R.class;AssetCryptImpl.class;VoxCinemasActivity.class;VoxCinemasAppInfo.class;VoxCinemasApplication.class" "-d" "E:\Titanium\voxcinemastitanium\build\android\bin\classes" "-proc:none" "-target" "1.6" "-source" "1.6" "#E:\Titanium\voxcinemastitanium\build\android\java-sources.txt"
[INFO] : Running dexer: C:\Program Files (x86)\Java\jdk1.7.0_79\bin\java.exe "-Xmx256M" "-XX:-UseGCOverheadLimit" "-Djava.ext.dirs=C:\Users\Ramesh\AppData\Local\Android\sdk\platform-tools" "-jar" "C:\Users\Ramesh\AppData\Local\Android\sdk\build-tools\23.0.1\lib\dx.jar" "--dex" "--output=E:\Titanium\voxcinemastitanium\build\android\bin\classes.dex" "E:\Titanium\voxcinemastitanium\build\android\bin\classes" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\lib\titanium-verify.jar" "E:\Titanium\voxcinemastitanium\modules\android\net.iamyellow.gcmjs\0.1\gcmjs.jar" "E:\Titanium\voxcinemastitanium\modules\android\net.iamyellow.gcmjs\0.1\lib\gcm.jar" "C:\ProgramData\Application Data\Titanium\modules\android\ti.map\2.3.3\map.jar" "C:\ProgramData\Application Data\Titanium\modules\android\ti.map\2.3.3\lib\google-play-services-base.jar" "C:\ProgramData\Application Data\Titanium\modules\android\ti.map\2.3.3\lib\google-play-services-map.jar" "E:\Titanium\voxcinemastitanium\modules\android\com.onecowstanding.flurry\1.1.1\flurry.jar" "E:\Titanium\voxcinemastitanium\modules\android\com.onecowstanding.flurry\1.1.1\lib\FlurryAgent.jar" "E:\Titanium\voxcinemastitanium\modules\android\analytics.google\3.1.0\analytics.google.jar" "E:\Titanium\voxcinemastitanium\modules\android\analytics.google\3.1.0\lib\google-play-services.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\kroll-v8.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-analytics.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\aps-analytics.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-android.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\jaxen-1.1.1.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\ti-commons-codec-1.3.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\kroll-common.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\titanium.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-app.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-ui.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\nineoldandroids-appc-2.4.0.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-filesystem.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-media.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-appcompat.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\android-support-v4.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\android-support-v7-appcompat.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-locale.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-network.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-xml.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-utils.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-geolocation.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-accelerometer.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-contacts.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-map.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-gesture.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-calendar.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-platform.jar" "C:\ProgramData\Titanium\mobilesdk\win32\5.0.0.GA\android\modules\titanium-database.jar"
[ERROR] : Failed to run dexer:
TRACE | titanium exited with exit code 1
[ERROR] Application Installer abnormal process termination. Process exit value was 1
Searching google leads to:
run
ti config android.dx.maxMemory 512M
source
perhaps that helps in your case, too. Otherwise please more information (code, platform, system specs). ti info helps
Phantomjs version - 1.9.7
Casperjs version - 1.1.0-beta3
This is the code
var casper = require('casper').create({
verbose: true,
logLevel: 'debug',
});
casper.start('https://www.gmail.com', function() {
casper.wait(3000, function() {
this.capture('gmail.png');
});
});
casper.run(function() {
this.exit();
});
The logs on Windows show
casperjs --ssl-protocol=any --ignore-ssl-errors=true login.js
[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[debug] [phantom] opening url: https://www.gmail.com/, HTTP GET
[debug] [phantom] Navigation requested: url=https://www.gmail.com/, type=Other, willNavigate=true, isMainFrame=true
[warning] [phantom] Loading resource failed with status=fail: https://www.gmail.com/
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 2/2: done in 349ms.
[info] [phantom] Step _step 3/3: done in 371ms.
[info] [phantom] wait() finished waiting for 3000ms.
[debug] [phantom] Capturing page to C:/Users/username/Desktop/gmail.png
[info] [phantom] Capture saved to C:/Users/username/Desktop/gmail.png
[info] [phantom] Done 3 steps in 3408ms
On OSX it shows the following
[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[debug] [phantom] opening url: https://www.gmail.com/, HTTP GET
[debug] [phantom] Navigation requested: url=https://www.gmail.com/, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=https://mail.google.com/mail/, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1<mpl=default<mplcache=2&emr=1, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1<mpl=default<mplcache=2&emr=1"
[debug] [phantom] Navigation requested: url=https://accounts.youtube.com/accounts/CheckConnection?pmpo=https://accounts.google.com&v=-320444755×tamp=1420230909413, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 2/2 https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1<mpl=default<mplcache=2&emr=1 (HTTP 200)
[info] [phantom] Step anonymous 2/2: done in 1398ms.
[info] [phantom] Step _step 3/3 https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1<mpl=default<mplcache=2&emr=1 (HTTP 200)
[info] [phantom] Step _step 3/3: done in 1418ms.
[info] [phantom] wait() finished waiting for 3000ms.
[debug] [phantom] Capturing page to /Users/username/code/casperjs/gmail.png
[info] [phantom] Capture saved to /Users/username/code/casperjs/gmail.png
[info] [phantom] Done 3 steps in 4511ms
The code is the same on both platforms, I have tried various combinations of --ignore-ssl-errors etc with no luck. Any suggestions?
Based on Artjom B.'s suggestions, I have updated the code like this -
var webPage = require('webpage');
var page = webPage.create();
var casper = require('casper').create({
verbose: true,
logLevel: 'debug',
pageSettings: {
userAgent: 'Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.41 Safari/535.1'
}
});
casper.on('resource.error', function(resource) {
this.echo('Error: ' +msg, 'ERROR'); });
casper.on("page.error", function(msg, trace) {
this.echo("Error: " + msg, "ERROR");
});
page.onResourceTimeout = function(request) {
console.log('Response (#' + request.id + '): ' + JSON.stringify(request));
};
casper.on("remote.message", function(msg, trace) {
this.echo("Error: " + msg, "ERROR");
});
casper.start('https://www.gmail.com', function() {
casper.wait(3000, function() {
this.capture('gmail.png');
});
});
casper.run(function() {
this.exit();
});
This gives the same result -
C:\Users\username\Desktop>casperjs --ssl-protocol=any --ignore-ssl-errors=true pt-login.js
[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[debug] [phantom] opening url: https://www.gmail.com/, HTTP GET
[debug] [phantom] Navigation requested: url=https://www.gmail.com/, type=Other, willNavigate=true, isMainFrame=true
[warning] [phantom] Loading resource failed with status=fail: https://www.gmail.com/
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 2/2: done in 338ms.
[info] [phantom] Step _step 3/3: done in 361ms.
[info] [phantom] wait() finished waiting for 3000ms.
[debug] [phantom] Capturing page to C:/Users/username/Desktop/gmail.png
[info] [phantom] Capture saved to C:/Users/username/Desktop/gmail.png
[info] [phantom] Done 3 steps in 3462ms
Relevant parts of my build.sbt are here:
libraryDependencies ++= Seq (
"org.scalatest" % "scalatest_2.10" % "1.9.1" % "test",
//Spray dependencies
"io.spray" % "spray-servlet" % "1.1-M7",
"com.typesafe.akka" %% "akka-actor" % "2.2-M3",
"com.typesafe.akka" %% "akka-slf4j" % "2.2-M3",
//Servlet API?
//"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" artifacts Artifact("javax.servlet", "jar", "jar"),
"javax.servlet" % "javax.servlet-api" % "3.0.1" % "provided",
"ch.qos.logback" % "logback-classic" % "1.0.12"
)
resolvers ++= Seq( "snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
"spray repo" at "http://repo.spray.io",
"typesafe repo" at "http://repo.typesafe.com/typesafe/releases/",
"releases" at "http://oss.sonatype.org/content/repositories/releases")
I get these same 12 errors no matter what I try to use for the servlet API (or maybe it's not the Servlet API at all?):
[info] Loading global plugins from /home/dkowis/.sbt/plugins
[info] Loading project definition from /home/dkowis/gitwork/turbo-jug-robot/project
[info] Set current project to turbo-jug-robot (in build file:/home/dkowis/gitwork/turbo-jug-robot/)
[info] Updating {file:/home/dkowis/gitwork/turbo-jug-robot/}default-5e44c0...
[info] Resolving javax.servlet#javax.servlet-api;3.0.1 ...
[info] Done updating.
[info] Compiling 2 Scala sources to /home/dkowis/gitwork/turbo-jug-robot/target/scala-2.10/classes...
[error] /home/dkowis/gitwork/turbo-jug-robot/src/main/scala/spray/examples/DemoService.scala:15: not found: value Uri
[error] case HttpRequest(GET, Uri.Path("/"), _, _, _) =>
[error] ^
[error] /home/dkowis/gitwork/turbo-jug-robot/src/main/scala/spray/examples/DemoService.scala:48: overloaded method value apply with alternatives:
[error] (optionalBody: Option[spray.http.HttpBody])spray.http.HttpEntity <and>
[error] (buffer: Array[Byte])spray.http.HttpEntity <and>
[error] (string: String)spray.http.HttpEntity
[error] cannot be applied to (spray.http.MediaType, String)
[error] entity = HttpEntity(`text/html`,
[error] ^
[error] /home/dkowis/gitwork/turbo-jug-robot/src/main/scala/spray/examples/DemoService.scala:18: not found: value Uri
[error] case HttpRequest(GET, Uri.Path("/ping"), _, _, _) =>
[error] ^
[error] /home/dkowis/gitwork/turbo-jug-robot/src/main/scala/spray/examples/DemoService.scala:21: not found: value Uri
[error] case HttpRequest(GET, Uri.Path("/stream"), _, _, _) =>
[error] ^
[error] /home/dkowis/gitwork/turbo-jug-robot/src/main/scala/spray/examples/DemoService.scala:25: not found: value Uri
[error] case HttpRequest(GET, Uri.Path("/crash"), _, _, _) =>
[error] ^
[error] /home/dkowis/gitwork/turbo-jug-robot/src/main/scala/spray/examples/DemoService.scala:30: not found: value Uri
[error] case HttpRequest(GET, Uri.Path("/timeout"), _, _, _) =>
[error] ^
[error] /home/dkowis/gitwork/turbo-jug-robot/src/main/scala/spray/examples/DemoService.scala:33: not found: value Uri
[error] case HttpRequest(GET, Uri.Path("/timeout/timeout"), _, _, _) =>
[error] ^
[error] /home/dkowis/gitwork/turbo-jug-robot/src/main/scala/spray/examples/DemoService.scala:38: not found: value Timedout
[error] case Timedout(HttpRequest(_, Uri.Path("/timeout/timeout"), _, _, _)) =>
[error] ^
[error] /home/dkowis/gitwork/turbo-jug-robot/src/main/scala/spray/examples/DemoService.scala:41: not found: value Timedout
[error] case Timedout(request: HttpRequest) =>
[error] ^
[error] /home/dkowis/gitwork/turbo-jug-robot/src/main/scala/spray/examples/DemoService.scala:42: not found: value request
[error] sender ! HttpResponse(500, "The " + request.method + " request to '" + request.uri + "' has timed out...")
[error] ^
[error] /home/dkowis/gitwork/turbo-jug-robot/src/main/scala/spray/examples/DemoService.scala:72: value withAck is not a member of spray.http.ChunkedResponseStart
[error] client ! ChunkedResponseStart(HttpResponse(entity = " " * 2048)).withAck(Ok(count))
[error] ^
[error] /home/dkowis/gitwork/turbo-jug-robot/src/main/scala/spray/examples/DemoService.scala:85: value withAck is not a member of spray.http.MessageChunk
[error] client ! MessageChunk(DateTime.now.toIsoDateTimeString + ", ").withAck(Ok(remaining - 1))
[error] ^
[error] 12 errors found
[error] (compile:compile) Compilation failed
[error] Total time: 4 s, completed May 25, 2013 1:32:40 PM
I'm truly at a loss as to what the proper dependencies are, and they're not exactly spelled out on the spray.io site. Or I'm dumb and can't figure out what the dependencies are.
Aha, turns out that the git master branch has newer, breaking changes in it, and so the examples aren't valid for any released artifacts. Using a tag in the repo, in my case 1.1-M7 made everything happy again.
Herp derp.
Is it possible via regular mvn command line client to browse the central repository, and possibly perform a specific search?
e.g: i want to get a list of all the artifacts that have "log4j" in their Artifact ID.
I whipped up a little Groovy script that does this:
import groovyx.net.http.URIBuilder
import groovy.json.JsonSlurper
class Fun {
public static void main(String[] args) {
def uri = new URIBuilder("http://search.maven.org/solrsearch/select")
uri.addQueryParam 'rows', 20
uri.addQueryParam 'wt', 'json'
uri.addQueryParam 'q', args[0]
def text = uri.toURL().getText()
def json = new JsonSlurper()
def result = json.parseText( text )
result.response.docs.each { doc ->
println "$doc.id:$doc.latestVersion"
}
}
}
And here's a Ruby script that does the same thing (using the httparty gem):
require 'httparty'
query = ARGV[0]
class MavenCentral
include HTTParty
base_uri 'search.maven.org'
def initialize(query, rows=20)
#options = { query: {rows: rows, wt: 'json', q: query} }
end
def artifacts
self.class.get('/solrsearch/select', #options)
end
end
maven_central = MavenCentral.new(query)
maven_central.artifacts['response']['docs'].each do |doc|
puts "#{doc['id']}:#{doc['latestVersion']}"
end
There is an SBT plugin for this: sbt-search-maven-plugin
$ sbt "searchMaven log4j"
[info] Loading global plugins from ~/.sbt/0.13/plugins
[info] Set current project to foo (in build file:~/projects/)
[info] Results for log4j:
[info] "com.jkoolcloud.tnt4j.logger" % "log4j" % "0.1"
[info] "org.apache.logging.log4j" % "log4j" % "2.6.1"
[info] "org.darkphoenixs" % "log4j" % "1.2.17"
[info] "log4j" % "log4j" % "1.2.17"
[info] "de.huxhorn.lilith" % "log4j" % "0.9.41"
[info] "org.mod4j.org.eclipse.xtext" % "log4j" % "1.2.15"
[info] "org.apache.logging.log4j" % "log4j-bom" % "2.6.1"
[info] "org.apache.logging.log4j.samples" % "log4j-samples" % "2.0.1"
[info] "org.apache.logging.log4j.osgi" % "log4j-osgi" % "2.0-rc1"
[info] "ro.fortsoft.log2j" % "log2j-parent" % "0.4"
[info] "ant" % "ant-apache-log4j" % "1.6.5"
[info] "ant" % "ant-jakarta-log4j" % "1.6.1"
[info] "plexus" % "plexus-log4j-logging" % "1.0"
[info] "org.apache.logging.log4j" % "log4j-liquibase" % "2.6.1"
[info] "org.apache.logging.log4j" % "log4j-jul" % "2.6.1"
[info] "org.apache.logging.log4j" % "log4j-iostreams" % "2.6.1"
[info] "org.apache.logging.log4j" % "log4j-nosql" % "2.6.1"
[info] "org.apache.logging.log4j" % "log4j-jmx-gui" % "2.6.1"
[info] "org.apache.logging.log4j" % "log4j-taglib" % "2.6.1"
[info] "org.apache.logging.log4j" % "log4j-web" % "2.6.1"
[success] Total time: 1 s, completed 24/06/2016 2:47:24 PM
mvn -q com.jarcasting:search-maven-plugin:search -Dq="com google guava"
search-maven-plugin
When successfully running >mvn package on an appfuse-basic-spring-archetype v2.1.0 project, the console output displays:
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # ScanillionAppTier02 ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 20 resources
[INFO] Copying 16 resources
[INFO] Copying 16 resources
[INFO] Copying 16 resources
I direct your attention to the last 3 lines (Copying 16...). I ran >mvn -X package to get DEBUG output, which shows that the resources plugin claims to be first filtering the 16 files and then copying them twice.
Even more copies happen within the forked hibernate3-maven-plugin:hbm2ddl portion of the build; in that section, the output shows the 16 files being filtered once and copied 4 times.
Again, the build works, so I could have (should have?) counted my blessings, averted my eyes, and got on with my project. Alas, I went down this rat hole and it's going to bug me until I get an answer. Help a guy get some sleep. :-)
EDIT 3/19/2012 cdhabecker: more detail
In the maven output with the -X option, I found this:
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-resources-plugin:2.5:resources' with basic configurator -->
[DEBUG] (f) buildFilters = []
[DEBUG] (f) encoding = UTF-8
[DEBUG] (f) escapeWindowsPaths = true
[DEBUG] (s) includeEmptyDirs = false
[DEBUG] (s) outputDirectory = C:\eclipse\workspace\foo\target\classes
[DEBUG] (s) overwrite = false
[DEBUG] (f) project = MavenProject: com.foo:foo:0.0.1-SNAPSHOT # C:\eclipse\workspace\foo\pom.xml
[LOOK] (s) resources = [Resource {targetPath: null, filtering: true, FileSet {directory: C:\eclipse\workspace\foo\src\main\resources, PatternSet [includes: {}, excludes: {ApplicationResources*.properties}]}},
[LOOK] Resource {targetPath: null, filtering: true, FileSet {directory: C:\eclipse\workspace\foo\target\resources, PatternSet [includes: {}, excludes: {}]}},
[LOOK] Resource {targetPath: null, filtering: false, FileSet {directory: C:\eclipse\workspace\foo\target\resources, PatternSet [includes: {}, excludes: {}]}},
[LOOK] Resource {targetPath: null, filtering: false, FileSet {directory: C:\eclipse\workspace\foo\target\resources, PatternSet [includes: {}, excludes: {}]}}]
[DEBUG] (f) session = org.apache.maven.execution.MavenSession#eddac
[DEBUG] (f) supportMultiLineFiltering = false
[DEBUG] (f) useBuildFilters = true
[DEBUG] (s) useDefaultDelimiters = true
[DEBUG] -- end configuration --
If you look at the lines marked [LOOK], you'll see that maven-resources thinks that it has 4 tasks (the filter of 20 files, the filter of 16 files, and the 2 redundant copies of those 16 files).
So now I suspect that something (e.g., native2ascii-maven-plugin or other plugins or the maven build plan generator) is registering those tasks with maven-resources-plugin and that nothing in the system is bothering to notice that some of those tasks are redundant.