How to use _emitProgress method in qawolf

Best JavaScript code snippet using qawolf

ame.ts

Source:ame.ts Github

copy

Full Screen

...153 this._isAborted = true;154 }155 private _lastEmitStatsResponse: IAMEJobStatusResponse = null;156 private _lastEmitStatus: AMEQueuedJobStatus = null;157 private _emitProgress(forceEmit: boolean = false): void158 {159 const cur = this._mostRecentStatus || this._submitStatus;160 const last = this._lastEmitStatsResponse;161 if (forceEmit || last == null || cur == null || (last.jobStatus != cur.jobStatus) || (last.jobProgress != cur.jobProgress) || (this._status != this._lastEmitStatus))162 this._safeEmit('progress', this);163 this._lastEmitStatsResponse = cur;164 this._lastEmitStatus = this._status;165 }166 private _safeEmit(eventName: string, eventArgs: any = undefined, dispatchViaImmediate: boolean = true)167 {168 const dispatch = () =>169 {170 try171 {172 this.emit(eventName, eventArgs);173 }174 catch (err)175 {176 }177 };178 if (dispatchViaImmediate === false) dispatch();179 else setImmediate(dispatch);180 }181 private _retrySubmit(wasBusy: boolean, failAction: string = 'failed')182 {183 this._status = AMEQueuedJobStatus.Pending;184 if (wasBusy || this._submitRetries-- > 0)185 {186 this._statusDetail = `Retrying submit to AME in ${this._submitRetryDelaySeconds}s (attempts left: ${this._submitRetries})`;187 this._log.info(`Retrying submit to AME in ${this._submitRetryDelaySeconds}s (attempts left: ${this._submitRetries})`);188 this._emitProgress(true);189 190 setTimeout(() => this._states.handle('submit'), 1000 * this._submitRetryDelaySeconds);191 }192 else193 {194 this._log.info("Exceeded submit retry limit, failing job..")195 this._statusDetail = "Exceeded submit retry limit, failing job..";196 this._emitProgress(true);197 this._states.handle(failAction);198 }199 }200 private _submit()201 {202 const [ log, ame ] = [ this._log, this._ame ];203 log.info('Submitting job to AME..');204 this._status = AMEQueuedJobStatus.Submitting;205 this._statusDetail = `(Attempts left: ${this._submitRetries})`;206 this._emitProgress();207 ame.client.submitJob(this._job).then(208 (status: IAMESubmitJobResponse) =>209 {210 this._submitStatus = status;211 log.info(`AME responded with submit status '${status.submitResultText}'`);212 switch (status.submitResult)213 {214 case AMESubmitResult.Accepted:215 log.info("AME accepted our job!");216 this._states.handle('accepted');217 this._emitProgress();218 break;219 case AMESubmitResult.BadSyntax:220 221 log.info("AME rejected our job claiming 'bad syntax' - can't recover!");222 this._states.handle('rejected');223 this._emitProgress();224 break;225 case AMESubmitResult.Rejected:226 log.info("AME rejected our job - will retry..");227 // We could just do this._stats.handle('rejected') but sometimes AME will228 // temporarily just fail jobs, probably because it is low on resources.229 //230 // Console output will be:231 //232 // Job request received.233 //234 // Source path: Z:\temp\render_jobs\57ce729f56222a640a89fca6\e10c9484-def6-47cf-a38d-e5fa5065e63f.mov235 // Output path: Z:\temp\render_jobs\57ce729f56222a640a89fca6\ITN_OYML050_030.mxf236 // Preset path: C:\Program Files\Adobe\Adobe Media Encoder CC 2015.3\MediaIO\systempresets\58444341_4D584658\XDCAMHD 50 PAL 50i.epr237 //238 //239 // Creating encoder.240 //241 // Creating Encoder - Timeout while creating encoder group242 this._retrySubmit(false, 'rejected');243 this._emitProgress();244 break;245 case AMESubmitResult.Busy:246 log.info("AME is busy processing some job..");247 this._retrySubmit(true);248 this._emitProgress();249 break;250 case AMESubmitResult.NoServer:251 log.info("AME is stopped..");252 this._retrySubmit(true);253 this._emitProgress();254 break;255 case AMESubmitResult.Unknown:256 default:257 log.error(`AME responded with unknown status '${status.submitResultText}'`)258 this._retrySubmit(false);259 this._emitProgress();260 return;261 }262 },263 (error: any) =>264 {265 log.error(`Error submitting job to AME: ${error.message}`);266 this._emitProgress();267 this._retrySubmit(false);268 }269 );270 }271 private _retryWait(isErrorState: boolean = false)272 {273 if (isErrorState)274 {275 if (this._waitErrorStateSince == null) this._waitErrorStateSince = Date.now();276 if ((Date.now() - this._waitErrorStateSince) / 1000 > this._errorStateTimeoutSeconds)277 {278 this._log.error('AME has been in an error state for too long - assuming that job has failed');279 // make a fake error state for the 'ended' state to pick up280 this._copySubmitStatus('AME has been in an error state for too long - assuming that job has failed')281 this._states.handle('end-check-history');282 return;283 }284 }285 setTimeout(() => this._states.handle('wait'), 1000);286 }287 private _waitForJobCompletion()288 {289 const [ log, ame ] = [ this._log, this._ame ];290 this._status = AMEQueuedJobStatus.Encoding;291 this._statusDetail = "";292 log.info("Querying AME job status..");293 ame.client.getJobStatus().then(294 (status: IAMEJobStatusResponse) =>295 {296 log.info(`Queried AME job status (${status.jobStatusText})`);297 if (status.jobId != this._submitStatus.jobId)298 {299 // the ended state must check the history300 log.warn(`AME is reporting a different current job than ours - probably finished processing it, must check server history for final result`);301 this._states.handle('end-check-history');302 return;303 }304 this._mostRecentStatus = status;305 switch (status.jobStatus)306 {307 case AMEJobStatus.Queued:308 case AMEJobStatus.Encoding:309 case AMEJobStatus.Paused:310 this._retryWait();311 break;312 case AMEJobStatus.NotFound:313 log.error(`AME reports no job found (server stopped?)`);314 this._states.handle('end-check-history');315 break;316 case AMEJobStatus.Stopped:317 log.error(`AME reports our job as stopped (aborted)`);318 this._status = AMEQueuedJobStatus.Aborted;319 this._statusDetail = `AME reports our job as stopped (aborted)`;320 this._states.handle('end');321 break;322 case AMEJobStatus.Failed:323 this._statusDetail = `AME reports our job as failed`;324 log.error(`AME reports our job as failed`);325 //this._status = AMEQueuedJobStatus.Failed; // let 'ended' figure this out326 this._states.handle('end');327 break;328 case AMEJobStatus.Success:329 log.info(`AME reports our job as successfully completed!`);330 this._status = AMEQueuedJobStatus.Succeeded;331 this._statusDetail = `AME reports our job as successfully completed!`;332 this._states.handle('end');333 break;334 case AMEJobStatus.Unknown:335 default:336 log.warn(`AME reports unknown job status '${status.jobStatus}'`);337 this._retryWait(true);338 break;339 }340 this._emitProgress();341 },342 (error: any) =>343 {344 log.warn(`AME is not responding`);345 this._retryWait(true);346 this._emitProgress();347 }348 )349 }350 private _copySubmitStatus(details: string = undefined, status: AMEJobStatus = AMEJobStatus.Failed)351 {352 // only copy if a recent status isn't set353 if (this._mostRecentStatus == null)354 this._mostRecentStatus = clone(this._submitStatus);355 356 // if the submit status was null, then fake one.. 357 if (this._mostRecentStatus == null)358 this._mostRecentStatus = <IAMEJobStatusResponse>{359 serverStatus: AMEServerStatus.Unknown,360 serverStatusText: AMEServerStatus[AMEServerStatus.Unknown], 361 jobId: '',362 jobStatus: AMEJobStatus.Unknown,363 jobStatusText: AMEQueuedJobStatus[AMEJobStatus.Unknown],364 jobProgress: undefined, 365 details: '(Job was never submitted to the server)'366 }367 // only update the status/details if the job didn't already complete by itself368 if (this._mostRecentStatus.jobStatus != AMEJobStatus.Success369 && this._mostRecentStatus.jobStatus != AMEJobStatus.Failed370 && this._mostRecentStatus.jobStatus != AMEJobStatus.Stopped)371 {372 this._mostRecentStatus.serverStatus = AMEServerStatus.Unknown;373 this._mostRecentStatus.serverStatusText = AMEServerStatus[AMEServerStatus.Unknown];374 this._mostRecentStatus.jobStatus = status;375 this._mostRecentStatus.jobStatusText = AMEJobStatus[status];376 if (details != undefined) this._mostRecentStatus.details = details;377 }378 }379 private _abortSubmitted()380 {381 const [ log, ame ] = [ this._log, this._ame ];382 this._status = AMEQueuedJobStatus.Aborting;383 this._statusDetail = `Attempting to abort submitted job in AME.. (attempts left: ${this._abortRetries})`;384 this._emitProgress(true);385 // check that it's our job still being processed..386 log.info("Getting AME job status before aborting job..");387 ame.client.getJobStatus().then(388 (status: IAMEJobStatusResponse) =>389 {390 if (status.jobId == this._submitStatus.jobId)391 {392 log.info("Telling AME to abort the current job..");393 ame.client.abortJob().then(394 () =>395 {396 log.info("AME reports job successfully aborted!");397 this._copySubmitStatus("Aborted upon request");398 this._status = AMEQueuedJobStatus.Aborted;399 this._statusDetail = "AME reports job successfully aborted!";400 this._emitProgress();401 },402 (error: any) =>403 {404 this._statusDetail = `Error while aborting AME job: ${error.message}`;405 log.error(this._statusDetail); 406 this._emitProgress(true);407 408 this._retryAbortSubmitted();409 }410 )411 }412 else413 {414 log.error("AME returns different current job than ours - must check history for final status");415 this._states.handle('end-check-history');416 this._emitProgress();417 }418 },419 (error: any) =>420 {421 log.error(`Error while requesting AME status before aborting job: ${error.message}`);422 this._retryAbortSubmitted();423 this._emitProgress();424 }425 );426 }427 private _retryAbortSubmitted()428 {429 if (this._abortRetries-- > 0)430 {431 this._statusDetail = `Retrying abort in ${this._abortRetryDelaySeconds}s (attempts left: ${this._abortRetries})`;432 this._log.info(this._statusDetail);433 this._emitProgress(true);434 435 setTimeout(() => this._states.handle('abort'), 1000 * this._abortRetryDelaySeconds)436 }437 else438 {439 this._statusDetail = `Number of retry attempts saturated - ending job..`; 440 this._log.info(this._statusDetail); 441 this._emitProgress(true);442 443 this._states.handle('end-check-history');444 }445 }446 private _checkHistoryForStatus()447 {448 const [ log, ame ] = [ this._log, this._ame ];449 // if we already have a status and it says something about a final450 // status, then there's no need to check the history..451 if (this._mostRecentStatus != null452 && (this._mostRecentStatus.jobStatus == AMEJobStatus.Success453 || this._mostRecentStatus.jobStatus == AMEJobStatus.Failed)454 )455 {456 this._states.handle('end');457 return;458 }459 log.info("Getting AME job history..");460 ame.client.getJobHistory().then(461 (history: IAMEJobHistoryResponse) =>462 {463 log.info("Got AME job history, trying to locate our job..")464 let found: boolean = false;465 if (history.historicJobs != null)466 history.historicJobs.every((h) =>467 {468 if (h.jobId == this._submitStatus.jobId)469 {470 log.info("Found our job in the AME history!", h)471 this._mostRecentStatus = <IAMEJobStatusResponse>{472 serverStatus: history.serverStatus,473 serverStatusText: history.serverStatusText,474 jobId: h.jobId,475 jobStatus: h.jobStatus,476 jobStatusText: h.jobStatusText,477 jobProgress: h.jobProgress, // usually not be set478 details: h.details479 };480 found = true;481 return false;482 }483 return true;484 });485 if (!found) log.error("Could not find our job in the AME history!");486 this._states.handle("end");487 },488 (error: any) =>489 {490 log.error(`Unable to get AME job history: ${error.message}`);491 // make a fake error state for the 'ended' state to pick up492 this._copySubmitStatus(`Unable to get AME job history: ${error.message}`); 493 this._states.handle("end");494 }495 )496 }497 private _ended()498 {499 const [ log, ame ] = [ this._log, this._ame ];500 const submitStatus = this._submitStatus;501 const lastStatus = this._mostRecentStatus;502 console.log(`ended, status=${this._status}`);503 if (this._status != AMEQueuedJobStatus.Aborted504 && this._status != AMEQueuedJobStatus.Failed505 && this._status != AMEQueuedJobStatus.Succeeded)506 {507 this._status = AMEQueuedJobStatus.Failed;508 this._copySubmitStatus();509 }510 this._emitProgress();511 this._safeEmit('ended', this);512 }513}514export class AdobeMediaEncoder extends events.EventEmitter515{516 private _options: IAdobeMediaEncoderOptions;517 private _client: AMEWebserviceClient;518 private _http: http.Server = null;519 private _log: ILogger = null;520 private _logFactory: ILoggerFactory;521 get client(): AMEWebserviceClient522 {523 return this._client;524 }...

Full Screen

Full Screen

ChoopsController.js

Source:ChoopsController.js Github

copy

Full Screen

...25 };26 async read(options) {27 this.progressTracker.totalSteps = 1;28 if (options && options.buildCache) {29 this._emitProgress(this.progressTracker.format('buildCache option passed in. Reading and building cache...'));30 await this.rebuildCache();31 }32 else {33 try {34 this._emitProgress(this.progressTracker.format('Cache found, reading data from cache...'));35 this.cache = await cacheUtil.getCache(cacheUtil.CACHES.CHOOPS.cache);36 this.cache.archiveCache.archives = this.cache.archiveCache.archives.map((entry) => {37 let archive = new Archive();38 archive.name = entry.name;39 archive.zero = entry.zero;40 archive.zero = entry.zero;41 archive.sizeRaw = entry.sizeRaw;42 return archive;43 });44 this.cache.tocCache = this.cache.tocCache.map((rawCacheEntry) => {45 let cacheEntry = new ChoopsCacheEntry();46 cacheEntry.id = rawCacheEntry.id;47 cacheEntry.size = rawCacheEntry.size;48 cacheEntry.nameHash = rawCacheEntry.nameHash;49 cacheEntry.name = rawCacheEntry.name;50 cacheEntry.rawOffset = rawCacheEntry.rawOffset;51 cacheEntry.offset = rawCacheEntry.offset;52 cacheEntry.location = rawCacheEntry.location;53 cacheEntry.isSplit = rawCacheEntry.isSplit;54 cacheEntry.splitSecondFileSize = rawCacheEntry.splitSecondFileSize;55 56 cacheEntry.original.id = rawCacheEntry.original.id;57 cacheEntry.original.size = rawCacheEntry.original.size;58 cacheEntry.original.nameHash = rawCacheEntry.original.nameHash;59 cacheEntry.original.name = rawCacheEntry.original.name;60 cacheEntry.original.rawOffset = rawCacheEntry.original.rawOffset;61 cacheEntry.original.offset = rawCacheEntry.original.offset;62 cacheEntry.original.location = rawCacheEntry.original.location;63 cacheEntry.original.isSplit = rawCacheEntry.original.isSplit;64 cacheEntry.original.splitSecondFileSize = rawCacheEntry.original.splitSecondFileSize;65 return cacheEntry;66 });67 this.data = this.cache.tocCache;68 }69 catch (err) {70 this._emitProgress(this.progressTracker.format('Cache not found or empty, reading and building cache...'));71 await this.rebuildCache();72 }73 }74 this._archiveWriter.cache = this.cache;75 this.progressTracker.step();76 this._emitProgress(this.progressTracker.format('Read complete.'));77 };78 async _read() {79 await hashUtil.hashLookupPromise;80 let cachePromises = [];81 this.parser.on('progress', function (data) {82 this._emitProgress(data);83 }.bind(this));84 this.parser.on('chunk', async function (data) {85 cachePromises.push(new Promise(async (resolve, reject) => {86 let cacheEntry = new ChoopsCacheEntry();87 cacheEntry.id = data.meta.id;88 cacheEntry.size = data.meta.size;89 cacheEntry.nameHash = data.meta.nameHash;90 const name = await hashUtil.hashLookup(cacheEntry.nameHash);91 if (!name) {92 cacheEntry.name = data.meta.id.toString();93 }94 else {95 cacheEntry.name = name.str;96 }97 cacheEntry.rawOffset = data.meta.rawOffset;98 cacheEntry.offset = data.meta.archiveOffset;99 cacheEntry.location = data.meta.archiveIndex;100 cacheEntry.isSplit = data.meta.isSplit;101 cacheEntry.splitSecondFileSize = data.meta.splitSecondFileSize;102 103 cacheEntry.setCurrentDataAsOriginal();104 resolve(cacheEntry);105 }));106 }.bind(this));107 const gameFilePaths = await gameFileUtil.getGameFilePaths(this.gameDirectoryPath);108 const gameReadStreams = gameFilePaths.map((gameFilePath) => {109 return fs.createReadStream(gameFilePath);110 });111 await new Promise((resolve, reject) => {112 pipeline(113 new Multistream(gameReadStreams),114 this.parser,115 (err) => {116 if (err) { reject(err); }117 else { resolve(); }118 }119 );120 });121 const cacheEntries = await Promise.all(cachePromises);122 this.data = cacheEntries;123 };124 async _buildCache() {125 this.cache = new ChoopsCache();126 this.cache.tocCache = this.data;127 this.cache.archiveCache = this.parser.archive;128 await this._saveCache();129 };130 async rebuildCache() {131 await this._read();132 await this._buildCache();133 };134 async _saveCache() {135 // build cache to save - we don't want to save any of the controllers136 let cacheToSave = JSON.parse(JSON.stringify(this.cache));137 cacheToSave.tocCache.forEach((cacheEntry) => {138 delete cacheEntry.controller;139 });140 await cacheUtil.buildAndSaveCache(cacheUtil.CACHES.CHOOPS.cache, cacheToSave);141 };142 getEntryByName(name) {143 const entry = this.data.find((entry) => {144 return entry.name.toLowerCase() === name.toLowerCase();145 });146 if (!entry) {147 throw new Error(`Cannot find a resource in the cache with name ${name}.`);148 }149 return entry;150 };151 // retrieve the raw buffer of a resource.152 async getFileRawData(name) {153 if (!name) { throw new Error('getResourceData() takes in a mandatory `name` parameter.'); }154 if (!this.data) { throw new Error('No data loaded. You must call the `read` function before calling this function.'); }155 this.progressTracker.reset();156 this.progressTracker.totalSteps = 2;157 this._emitProgress(this.progressTracker.format('Searching for entry in cache...'));158 const entry = this.getEntryByName(name);159 160 let entryBuf = Buffer.alloc(entry.size);161 const entryPath = await gameFileUtil.getGameFilePathByIndex(this.gameDirectoryPath, entry.location);162 this.progressTracker.step();163 this._emitProgress(this.progressTracker.format(`Reading resource from path: ${entryPath} @ offset 0x${entry.offset.toString(16)}.`));164 await this._openAndReadFile(entryPath, entryBuf, entry.size, entry.offset);165 if (entry.isSplit) {166 let entryBuf2 = Buffer.alloc(entry.splitSecondFileSize);167 const entryPath2 = await gameFileUtil.getGameFilePathByIndex(this.gameDirectoryPath, entry.location + 1);168 this.progressTracker.totalSteps += 1;169 this.progressTracker.step();170 this._emitProgress(this.progressTracker.format(`Data is split between two files. Continuing to read from path: ${entryPath2} @ offset 0x0.`));171 await this._openAndReadFile(entryPath2, entryBuf2, entry.splitSecondFileSize, 0);172 entryBuf = entryBuf.slice(0, entry.size - entry.splitSecondFileSize);173 entryBuf = Buffer.concat([entryBuf, entryBuf2]);174 }175 this.progressTracker.step();176 this._emitProgress(this.progressTracker.format('Done reading resource.'));177 return entryBuf;178 };179 async _openAndReadFile(path, buf, length, offset) {180 const fd = await fsPromies.open(path, 'r+');181 await fd.read({182 buffer: buf,183 offset: 0,184 length: length,185 position: offset186 });187 await fd.close();188 };189 async getFileController(name) {190 let entry = this.getEntryByName(name);191 const resourceRawData = await this.getFileRawData(name);192 if (resourceRawData.readUInt32BE(0) === 0xFF3BEF94) {193 const resourceDataStream = Readable.from(resourceRawData);194 195 this.progressTracker.totalSteps += 1;196 this._emitProgress(this.progressTracker.format('Parsing IFF...'));197 198 let controller = await new Promise((resolve, reject) => {199 const parser = new IFFReader();200 201 pipeline(202 resourceDataStream,203 parser,204 (err) => {205 if (err) reject(err);206 else resolve(parser.controller);207 }208 )209 });210 211 entry.controller = controller;212 213 this.progressTracker.step();214 this._emitProgress(this.progressTracker.format('Done parsing IFF.'));215 return controller;216 }217 else {218 return resourceRawData;219 }220 };221 async repack() {222 await this._archiveWriter.write();223 await this._saveCache();224 };225 async revert(name) {226 let entry = this.getEntryByName(name);227 entry.revert();228 // need logic to bump the location by 1 if the files are still modified229 // if (this.cache.archiveCache.archives.length > 5) {230 // entry.location += 1;231 // entry.offset 232 // }233 let archiveCacheEntry = this.cache.archiveCache.toc.find((tocEntry) => {234 return tocEntry.id === entry.id;235 });236 archiveCacheEntry.archiveIndex = entry.location;237 archiveCacheEntry.archiveOffset = entry.offset;238 archiveCacheEntry.rawOffset = entry.rawOffset;239 archiveCacheEntry.size = entry.size;240 archiveCacheEntry.isSplit = entry.isSplit;241 archiveCacheEntry.splitSecondFileSize = entry.splitSecondFileSize;242 delete entry.controller; 243 };244 async revertAll() {245 await this._archiveWriter.revertAll();246 await this.rebuildCache();247 };248 _emitProgress(message) {249 this.emit('progress', message);250 };251};...

Full Screen

Full Screen

old.js

Source:old.js Github

copy

Full Screen

...121 if (this.bytesWritten === this.file.size) { // Already done!122 if (this.options.resetAfter === true) {123 this._urlCache(false);124 }125 this._emitProgress(range_from, this.file.size);126 this._emitDone();127 return;128 }129 this._urlCache(this.fileUrl);130 this._emitProgress();131 let bytesWrittenAtStart = this.bytesWritten;132 let slice = this.file.slice || this.file.webkitSlice || this.file.mozSlice;133 let blob = slice.call(this.file, range_from, range_to + 1, this.file.type);134 let xhr = new XMLHttpRequest();135 this.uploadRequest = xhr;136 xhr.upload.addEventListener('progress', e => {137 this.bytesWritten = bytesWrittenAtStart + e.loaded;138 if (e && e.lengthComputable) {139 this._emitProgress(range_from + e.loaded, this.file.size);140 }141 });142 xhr.upload.addEventListener('load', () => {143 if (this.options.resetAfter === true) {144 this._urlCache(false);145 }146 this._emitDone();147 });148 xhr.upload.addEventListener('error', () => {149 var msg = xhr.responseText || xhr.status;150 this._emitFail(msg);151 });152 xhr.upload.addEventListener('abort', () => {153 console.log('Stop uploading!');154 });155 xhr.open('PATCH', this.fileUrl);156 xhr.setRequestHeader('Offset', range_from);157 xhr.setRequestHeader('Content-Type', 'application/offset+octet-stream');158 xhr.onreadystatechange = () => {159 if (xhr.readyState === 4) {160 if (xhr.status === 200) {161 } else {162 let msg = xhr.responseText || xhr.status;163 this._emitFail(msg);164 }165 }166 };167 xhr.send(blob);168 }169 _urlCache(url) {170 let fingerPrint = this.options.fingerprint;171 if (url === false) {172 return localStorage.removeItem(fingerPrint);173 }174 if (url) {175 let result = false;176 try {177 result = localStorage.setItem(fingerPrint, url);178 } catch (e) {179 // most likely quota exceeded error180 }181 return result;182 }183 return localStorage.getItem(fingerPrint);184 }185 _emitProgress(loaded, total) {186 this.progress && this.progress(loaded, total);187 }188 _emitDone() {189 this.done && this.done();190 }191 _emitFail(err) {192 this.fail && this.fail(err);193 }...

Full Screen

Full Screen

jquery.tus.js

Source:jquery.tus.js Github

copy

Full Screen

...112 this.bytesWritten = range_from;113 if (this.bytesWritten === this.file.size) {114 // Cool, we already completely uploaded this.115 // Update progress to 100%.116 this._emitProgress();117 return this._emitDone();118 }119 this._urlCache(self.fileUrl);120 this._emitProgress();121 var bytesWrittenAtStart = this.bytesWritten;122 var slice = self.file.slice || self.file.webkitSlice || self.file.mozSlice;123 var blob = slice.call(self.file, range_from, range_to + 1, self.file.type);124 var xhr = $.ajaxSettings.xhr();125 var options = {126 type: 'PATCH',127 url: self.fileUrl,128 data: blob,129 processData: false,130 contentType: self.file.type,131 cache: false,132 xhr: function() {133 return xhr;134 },135 headers: {136 'Offset': range_from137 }138 };139 $(xhr.upload).bind('progress', function(e) {140 self.bytesWritten = bytesWrittenAtStart + e.originalEvent.loaded;141 self._emitProgress(e);142 });143 this._jqXHR = $.ajax(options)144 .fail(function(jqXHR, textStatus, errorThrown) {145 // @TODO: Compile somewhat meaningful error146 // Needs to be cleaned up147 // Needs to have retry148 var msg = jqXHR.responseText || textStatus || errorThrown;149 self._emitFail(msg);150 })151 .done(function() {152 console.log('done', arguments, self, self.fileUrl);153 if (self.options.resetAfter === true) {154 self._urlCache(false);155 }...

Full Screen

Full Screen

api.service.ts

Source:api.service.ts Github

copy

Full Screen

...56 }57 getIdentity() {58 return this._http.get('/api/identity').map(res => res.json());59 }60 private _emitProgress() {61 this.fetchingResultsStateSubject.next(this._fetchingState);62 }63 private _fetchBuyer(buyer) {64 if (this._buyerCache[buyer]) return this._buyerCache[buyer];65 const fetch = new ReplaySubject();66 const localKey = `buyer-${buyer}`;67 let local = localStorage.getItem(localKey);68 if (local) {69 fetch.next(JSON.parse(local));70 return fetch;71 }72 this._buyerCache[buyer] = fetch;73 this._http.get(`/api/buyer/${buyer}`).map(res => res.json()).subscribe(res => {74 fetch.next(res);75 localStorage.setItem(localKey, JSON.stringify(res));76 });77 return fetch;78 }79 private _fetchSeller(seller) {80 if (this!._sellerCache[seller]) return this._sellerCache[seller];81 const fetch = new ReplaySubject();82 const localKey = `seller-${seller}`;83 let local = localStorage.getItem(localKey);84 if (local) {85 fetch.next(JSON.parse(local));86 return fetch;87 }88 this._sellerCache[seller] = fetch;89 this._http.get(`/api/seller/${seller}`).map(res => res.json()).subscribe(res => {90 fetch.next(res);91 localStorage.setItem(localKey, JSON.stringify(res));92 });93 94 return fetch;95 }96 private _pollBuyerState(buyer) {97 return IntervalObservable.create(1000)98 .flatMap(() => this._http.get(`/api/status/buyer/${buyer}`)).map(res => res.json());99 }100 private _pollSellerState(seller) {101 return IntervalObservable.create(1000)102 .flatMap(() => this._http.get(`/api/status/seller/${seller}`)).map(res => res.json());103 }104 private _resetProgress(buyerName, sellerName) {105 this._fetchingState.buyer.name = buyerName;106 this._fetchingState.buyer.progress = 0;107 this._fetchingState.seller.name = sellerName;108 this._fetchingState.seller.progress = 0;109 this._emitProgress();110 }111 private _setBuyerProgress(progress) {112 this._fetchingState.buyer.progress = progress;113 this._emitProgress();114 }115 private _setSellerProgress(progress) {116 this._fetchingState.seller.progress = progress;117 this._emitProgress();118 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2qawolf._emitProgress("test", 1, 2);3const qawolf = require("qawolf");4qawolf._emitProgress("test", 1, 2);5const qawolf = require("qawolf");6qawolf._emitProgress("test", 1, 2);7const qawolf = require("qawolf");8qawolf._emitProgress("test", 1, 2);9const qawolf = require("qawolf");10qawolf._emitProgress("test", 1, 2);11const qawolf = require("qawolf");12qawolf._emitProgress("test", 1, 2);13const qawolf = require("qawolf");14qawolf._emitProgress("test", 1, 2);15const qawolf = require("qawolf");16qawolf._emitProgress("test", 1, 2);17const qawolf = require("qawolf");18qawolf._emitProgress("test", 1, 2);19const qawolf = require("qawolf");20qawolf._emitProgress("test", 1, 2);21const qawolf = require("qawolf");22qawolf._emitProgress("test

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2qawolf._emitProgress(0.5, "progress message");3const qawolf = require("qawolf");4qawolf._emitProgress(0.5, "progress message");5const qawolf = require("qawolf");6qawolf._emitProgress(0.5, "progress message");7const qawolf = require("qawolf");8qawolf._emitProgress(0.5, "progress message");

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Runner } = require("qawolf");2const runner = new Runner();3runner._emitProgress('Test message');4"scripts": {5 }6const { Runner } = require("qawolf");7const runner = new Runner();8runner.on("progress", (message) => {9 console.log(message);10});11"scripts": {12 }13const { Runner } = require("qawolf");14const runner = new Runner();15runner._emitProgress('Test message');16"scripts": {17 }18const { Runner } = require("qawolf");19const runner = new Runner();20runner.on("progress", (message) => {21 console.log(message);22});23"scripts": {24 }

Full Screen

Using AI Code Generation

copy

Full Screen

1const { _emitProgress } = require("qawolf");2_emitProgress("progressMessage");3_emitProgress("progressMessage", 10);4_emitProgress("progressMessage", 10, 20);5_emitProgress("progressMessage", 10, 20, 2);6_emitProgress("progressMessage", 10, 20, 2, 1234);7_emitProgress("progressMessage", 10, 20, 2, 1234, 1234);8_emitProgress("progressMessage", 10, 20, 2, 1234, 1234, "errorMessage");9_emitProgress("progressMessage", 10, 20, 2, 1234, 1234, "errorMessage", "errorStack");10_emitProgress("progressMessage", 10, 20, 2, 1234, 1234, "errorMessage", "errorStack", "errorType");11_emitProgress("progressMessage", 10, 20, 2, 1234, 1234, "errorMessage", "errorStack", "errorType", "errorCode");12_emitProgress("progressMessage", 10, 20, 2, 1234, 1234, "errorMessage", "errorStack", "errorType", "errorCode", "errorDetails");

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run qawolf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful