/* This progress meter spews as little output as possible. It uses * no backspaces or ANSI escapes nor does it ask for transfer stats to * be printed. */ int PrDots(XferSpecPtr xp, int mode) { static int dotsPrinted; int newDots; switch (mode) { case kPrInitMsg: dotsPrinted = 0; EPrintF("%s: ", xp->localFileName); break; case kPrUpdateMsg: if (xp->expectedSize <= 0) newDots = 10; else newDots = (LOCALSIZE(xp) * 10 / xp->expectedSize) + 1; while ((dotsPrinted < newDots) && (dotsPrinted < 10)) { EPrintF("."); dotsPrinted++; } break; case kPrEndMsg: for (; dotsPrinted < 10; dotsPrinted++) EPrintF("."); EPrintF("\n"); break; } return 0; } /* PrDots */
void call_init() { Object *instance = POP(); // TODO CHECK Function* f = static_cast<Function *>(instance->getfield("__init__")); int localsize = LOCALSIZE(); PUSH(f); if (f != NULL) { PUSH(instance); for (int i=0; i<localsize; i++) PUSH(GETLOCAL(i)); DEBUG_LOG(cerr << "calling __init__ with" << localsize + 1 << endl;)
/* This should be called after each "block" in the transfer. We check * here to see if we should bother updating the progress meter. We * won't update if we had already updated within the last second or so. */ void ProgressReport(XferSpecPtr xp, int forceUpdate) { double frac; #ifdef SIGTSTP Sig_t sts; #endif if (xp->doReports) { /* Check the current time. */ (void) Gettimeofday(&xp->endTime); /* Won't update unless it's past the 'timeOfNextUpdate' * or we got a message saying to do your last update. */ if ((xp->endTime.tv_sec > xp->timeOfNextUpdate) || forceUpdate) { /* Won't do updates anymore if we get backgrounded. */ xp->doReports = InForeGround(); if (xp->doReports != 0) { #ifdef SIGTSTP /* The user could hit ^Z right when we are trying to do * a progress report. This could mean that as soon as the * user put the program in the background, we would output * the progress report, which would suspend the process * because of tty output. * * We try to avoid that scenario by temporarily putting off * the ^Z, doing the progress report, then sending us the * suspend signal again. */ sts = SIGNAL(SIGTSTP, SIG_IGN); if (sts != SIG_IGN) { gStoppedInProgressReport = 0; SIGNAL(SIGTSTP, ProgressSuspsend); } #endif /* Figure out how long the transfer has been going. */ TimeValSubtract(&gElapsedTVal, &xp->endTime, &xp->startTime); /* Get current transfer duration. */ xp->secsElap = (gElapsedTVal.tv_usec / 1000000.0) + gElapsedTVal.tv_sec; /* Get current transfer rate. */ if ((xp->secsElap <= 0.0) || (xp->bytesTransferred == 0)) { xp->bytesPerSec = 1.0; /* Don't set to 0. */ } else { xp->bytesPerSec = ((double) xp->bytesTransferred) / xp->secsElap; } /* Compute how much we've done so far, if we can. */ if (xp->expectedSize > 0) { xp->bytesLeft = xp->expectedSize - LOCALSIZE(xp); frac = (double) LOCALSIZE(xp) / (double) xp->expectedSize; if (frac > 1.0) frac = 1.0; else if (frac < 0.0) frac = 0.0; xp->frac = frac; } else { xp->frac = 0.0; } /* Have this progress meter do its thing. */ (*xp->prProc)(xp, kPrUpdateMsg); FlushListWindow(); /* Compute the next update time. */ xp->timeOfNextUpdate = xp->endTime.tv_sec + kDelaySeconds - 1; #ifdef SIGTSTP if (sts != SIG_IGN) { SIGNAL(SIGTSTP, sts); if (gStoppedInProgressReport != 0) kill(getpid(), SIGTSTP); } #endif /* Figure out how long the transfer has been going. */ } else { return; } } /* Won't do reports if the user isn't logged in to see them. */ xp->doReports = UserLoggedIn(); } } /* ProgressReport */