コード例 #1
0
ファイル: repho.py プロジェクト: M4rtinK/repho
  def __init__(self):
    # log start
    initTs = time.clock()
    self.startupTimeStamp = time.time()

    # parse startup arguments
    start = startup.Startup()
    args = start.args

    # restore the persistent options dictionary
    self.d = {}
    self.options = options.Options(self)
    # options value watching
    self.maxWatchId = 0
    self.watches = {}

    initialSize = (854,480)


    # get the platform module
    self.platform = None

    if args.p:
      if args.p == "maemo5":
        import maemo5
        self.platform = maemo5.Maemo5(self, GTK=False)
      elif args.p == "harmattan":
        import harmattan
        self.platform = harmattan.Harmattan(self)
      else:
        import pc
        self.platform = pc.PC(self)

    else:
      # no platform provided, fallback to PC module
      import pc
      self.platform = pc.PC(self)


    # create the GUI
    startTs1 = timer.start()

    # RePho currently has only a single GUI module
    self.gui = gui.getGui(self, 'QML', accel=True, size=initialSize)

    timer.elapsed(startTs1, "GUI module import")

    # check if a path was specified in the startup arguments
    if args.o != None:
      try:
        print("loading manga from: %s" % args.o)
        self.setActiveManga(self.openManga(args.o))
        print('manga loaded')
      except Exception, e:
        print("loading manga from path: %s failed" % args.o)
        print(e)
コード例 #2
0
def update_display(timeline=None):
    if timer.running():
        time_elapsed.set_text(timer.elapsed())
        time_remaining.set_text(timer.remaining())

        progress = timer.progress()

        if 1 <= timer.seconds_remaining() <= 60:
            global alternate_black
            alternate_black = not alternate_black

            if alternate_black:
                stage.set_color(black)
            else:
                stage.set_color(red)
        elif timer.duration <= datetime.timedelta(minutes=20):
            if 0.0 <= progress <= 0.4:
                stage.set_color(green)
            elif 0.4 <= progress <= 0.6:
                stage.set_color(yellow)
            elif 0.6 <= progress <= 0.7:
                stage.set_color(orange)
            else:
                stage.set_color(red)
        else:
            if 0.0 <= progress <= 0.5:
                stage.set_color(green)
            elif 0.5 <= progress <= 0.75:
                stage.set_color(yellow)
            elif 0.75 <= progress <= 0.95:
                stage.set_color(orange)
            else:
                stage.set_color(red)
    else:
        time_remaining.set_text(input.to_string())

        if absolute_time:
            stage.set_color(darkgrey)
            time_elapsed.set_text(time.strftime("%H:%M:%S", time.localtime()))
            # Show the absolute labels?
        else:
            stage.set_color(black)
            time_elapsed.set_text(timer.elapsed())
コード例 #3
0
    def completePackage(self, header, timer):
        def formatTime(amt):
            hours = amt / 60 / 60
            amt = amt % (60 * 60)
            min = amt / 60
            amt = amt % 60
            secs = amt

            return "%01d:%02d:%02d" % (int(hours), int(min), int(secs))

        self.numComplete = self.numComplete + 1

        self.sizeComplete = self.sizeComplete + (header[rpm.RPMTAG_SIZE] /
                                                 1024)

        # check to see if we've started yet
        elapsedTime = timer.elapsed()
        if not elapsedTime:
            elapsedTime = 1

        if self.sizeComplete != 0:
            finishTime = (float(self.totalSize) /
                          self.sizeComplete) * elapsedTime
        else:
            finishTime = (float(self.totalSize) /
                          (self.sizeComplete + 1)) * elapsedTime

        remainingTime = finishTime - elapsedTime

        self.setStatusRow(self.completed_iter, [
            _("Completed"),
            "%d" % (self.numComplete, ),
            "%d M" % (self.sizeComplete / 1024, ),
            "%s" % (formatTime(elapsedTime), )
        ])

        self.setStatusRow(self.total_iter, [
            _("Total"),
            "%d" % (self.numTotal, ),
            "%d M" % (self.totalSize / 1024, ),
            "%s" % (formatTime(finishTime), )
        ])

        self.setStatusRow(self.remaining_iter, [
            _("Remaining"),
            "%d" % ((self.numTotal - self.numComplete), ),
            "%d M" % ((self.totalSize / 1024 - self.sizeComplete / 1024), ),
            "%s" % (formatTime(remainingTime), )
        ])

        self.totalProgress.set_fraction(
            float(self.sizeComplete) / self.totalSize)

        return
コード例 #4
0
ファイル: panora.py プロジェクト: M4rtinK/panora
  def __init__(self):
    # log start
    initTs = time.clock()
    self.startupTimeStamp = time.time()

    # parse startup arguments
    start = startup.Startup()
    args = start.args
    self.args = args

    # restore the persistent options dictionary
    self.d = {}
    self.options = options.Options(self)
    # options value watching
    self.maxWatchId = 0
    self.watches = {}

    initialSize = (854, 480)

    # get the platform module
    self.platform = None
    # get the platform ID string
    platformId = "harmattan" # safe fallback
    if args.p is None:
      import platform_detection
      # platform detection
      result = platform_detection.getBestPlatformModuleId()
      if result:
        platformId = result
    else: # use the CLI provided value
      platformId = args.p

    if platformId == "harmattan":
      import harmattan

      self.platform = harmattan.Harmattan(self)
    else:
      print("can't start: current platform unknown")
      sys.exit(1)

    # create the GUI
    startTs1 = timer.start()

    # Panora currently has only a single QML based GUI module
    self.gui = gui.getGui(self, 'QML', accel=True, size=initialSize)

    timer.elapsed(startTs1, "GUI module import")
    timer.elapsed(initTs, "Init")
    timer.elapsed(startTs, "Complete startup")

    # start the main loop
    self.gui.startMainLoop()
コード例 #5
0
ファイル: mieru.py プロジェクト: disciple961/mieru
    def __init__(self):
        # log start
        initTs = time.clock()
        self.startupTimeStamp = time.time()

        # parse startup arguments
        start = startup.Startup()
        args = start.args
        self.args = args
        self.originalCWD = originalCWD

        # restore the persistent options dictionary
        self.d = {}
        self.options = options.Options(self)
        # options value watching
        self.maxWatchId = 0
        self.watches = {}
        # history lock
        self.historyLock = RLock()  # NOTE: not yet used

        # enable stats
        self.stats = stats.Stats(self)

        self.continuousReading = True

        # get the platform module
        self.platform = None

        # get the platform ID string
        platformId = "pc"  # safe fallback
        if args.p is None:
            import platform_detection
            # platform detection
            result = platform_detection.getBestPlatformModuleId()
            if result:
                platformId = result
        else:  # use the CLI provided value
            platformId = args.p

        if platformId:
            if platformId == "maemo5":
                import maemo5

                if args.u == "hildon":  # enable app menu with Hildon gui
                    self.platform = maemo5.Maemo5(self, GTK=True)
                else:
                    self.platform = maemo5.Maemo5(self, GTK=False)
            elif platformId == "harmattan":
                import harmattan

                self.platform = harmattan.Harmattan(self)
            else:
                import pc

                self.platform = pc.PC(self)

        else:
            # no platform provided, decide based on selected GUI
            if args.u == "hildon":
                import maemo5

                self.platform = maemo5.Maemo5(self, GTK=True)
            elif args.u == "harmattan":
                import harmattan

                self.platform = harmattan.Harmattan(self)
            else:
                import pc

                self.platform = pc.PC(self)

        # create the GUI
        startTs1 = timer.start()

        # use CLI provided GUI module ID
        if args.u:
            self._loadGUIModule(args.u)
        else:  # get GUI module id from the platform module
            ids = self.platform.getSupportedGUIModuleIds()
            if ids:
                guiModuleId = ids[0]
                print('preferred GUI ID from platform module: %s' %
                      guiModuleId)
                self._loadGUIModule(guiModuleId)
            else:
                print(
                    "platform module error: list of supported GUI IDs is empty"
                )

        timer.elapsed(startTs1, "GUI module import")

        #    # resize the viewport when window size changes
        #    self.gui.resizeNotify(self._resizeViewport)

        self.activeManga = None

        # check if a path was specified in the startup arguments
        if args.o is not None:
            try:
                print("loading manga from: %s" % args.o)
                self.setActiveManga(self.openManga(args.o, checkHistory=True))
                print('manga loaded')
            except Exception, e:
                print("loading manga from path: %s failed" % args.o)
                print(e)
コード例 #6
0
ファイル: mieru.py プロジェクト: disciple961/mieru
# -*- coding: utf-8 -*-
from __future__ import with_statement  # for python 2.5
import gs

import timer
import time
from threading import RLock

# Mieru modules import
startTs = timer.start()
import manga
import options
import startup
import stats

timer.elapsed(startTs, "All modules combined")

# set current directory to the directory
# of this file
# like this, Mieru can be run from absolute path
# eq.: ./opt/mieru/mieru.py -p harmattan -u harmattan
import os

originalCWD = os.getcwd()

abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)

# append the platform modules folder to path
import sys
コード例 #7
0
ファイル: progress_gui.py プロジェクト: abelboldu/anaconda-ee
    def completePackage(self, header, timer):
        def formatTime(amt):
            hours = amt / 60 / 60
            amt = amt % (60 * 60)
            min = amt / 60
            amt = amt % 60
            secs = amt

            return "%01d:%02d:%02d" % (int(hours) ,int(min), int(secs))

        self.numComplete = self.numComplete + 1

	self.sizeComplete = self.sizeComplete + (header[rpm.RPMTAG_SIZE]/1024)
        
	self.filesComplete = self.filesComplete + (len(header[rpm.RPMTAG_BASENAMES]))

        #crude fix for the completed packages overflow
        if self.numComplete>self.numTotal:
            self.numTotal = self.numComplete
        if self.sizeComplete>self.totalSize:
            self.totalSize = self.sizeComplete
        if self.filesComplete>self.totalFiles:
            self.totalFiles = self.filesComplete

        # check to see if we've started yet
	elapsedTime = timer.elapsed()
	if not elapsedTime:
	    elapsedTime = 1
	
        if self.sizeComplete != 0:
            finishTime1 = (float (self.totalSize) / self.sizeComplete) * elapsedTime
	else:
            finishTime1 = (float (self.totalSize)) * elapsedTime
		
	if  self.numComplete != 0:
            finishTime2 = (float (self.numTotal) / self.numComplete) * elapsedTime
	else:
	    finishTime2 = (float (self.numTotal)) * elapsedTime


	if self.filesComplete != 0:	    
	    finishTime3 = (float (self.totalFiles) / self.filesComplete) * elapsedTime
	else:
	    finishTime3 = (float (self.totalFiles)) * elapsedTime

	finishTime = finishTime1
# another alternate suggestion
#	finishTime = math.sqrt(finishTime1 * finishTime2)

	remainingTime = finishTime - elapsedTime

	fractionComplete = float(self.sizeComplete)/float(self.totalSize)

	timeest = 1.4*remainingTime/60.0

	# average last 10 estimates
	self.estimateHistory.append(timeest)
	if len(self.estimateHistory) > 10:
	    del self.estimateHistory[0]
	tavg = 0.0
	for testimate in self.estimateHistory:
	    tavg += testimate

	timeest = tavg/float(len(self.estimateHistory))

        # here is strategy for time estimate
	#
	# 1) First 100 or so packages give us misleading estimates as things
        #    are not settled down. So no estimate until past 100 packages
	#
	# 2) Time estimate based on % of bytes installed is on about 30% too
	#    low overall. So we just bump our estimate to compensate
	#
	# 3) Lets only report time on 5 minute boundaries, and round up.
	#

#	self.timeLog.write("%s %s %s %s %s %s %s %s %s %s %s %s\n" % (elapsedTime/60.0, (finishTime1-elapsedTime)/60.0, (finishTime2-elapsedTime)/60.0, (finishTime3-elapsedTime)/60.0, (finishTime-elapsedTime)/60.0, timeest, self.sizeComplete, self.totalSize, self.numComplete, self.numTotal, self.filesComplete, self.totalFiles, ))
#	self.timeLog.flush()

#	if (fractionComplete > 0.10):
        if self.numComplete > 100:
	    if self.initialTimeEstimate is None:
		self.initialTimeEstimate = timeest
		log.info("Initial install time estimate = %s", timeest)

#	    log.info("elapsed time, time est, remaining time =  %s %s", int(elapsedTime/60), timeest)		

            if timeest < 10:
	        timefactor = 2
	    else:
		timefactor = 5
	    str = _("Remaining time: %s minutes") % ((int(timeest/timefactor)+1)*timefactor,)
	    self.remainingTimeLabel.set_text(str)

	if (fractionComplete >= 1):
	    log.info("Actual install time = %s", elapsedTime/60.0)
	    self.remainingTimeLabel.set_text("")
	    
        self.totalProgress.set_fraction(fractionComplete)
	
        return
コード例 #8
0
ファイル: panora.py プロジェクト: M4rtinK/panora
#!/usr/bin/env python
from __future__ import with_statement # for python 2.5
import subprocess
from gui import gui

import timer
import time
from threading import RLock

# Panora modules import
startTs = timer.start()
import options
import startup

timer.elapsed(startTs, "All modules combined")

# set current directory to the directory
# of this file
# like this, Panora can be run from absolute path
# eq.: ./opt/panora/panora.py -p harmattan -u harmattan
import os

abspath = os.path.abspath(__file__)
dName = os.path.dirname(abspath)
os.chdir(dName)

# append the platform modules folder to path
import sys

sys.path.append('platforms')
コード例 #9
0
    def completePackage(self, header, timer):
        def formatTime(amt):
            hours = amt / 60 / 60
            amt = amt % (60 * 60)
            min = amt / 60
            amt = amt % 60
            secs = amt

            return "%01d:%02d:%02d" % (int(hours), int(min), int(secs))

        self.numComplete = self.numComplete + 1

        self.sizeComplete = self.sizeComplete + (header[rpm.RPMTAG_SIZE] /
                                                 1024)

        self.filesComplete = self.filesComplete + (len(
            header[rpm.RPMTAG_BASENAMES]))

        # check to see if we've started yet
        elapsedTime = timer.elapsed()
        if not elapsedTime:
            elapsedTime = 1

        if self.sizeComplete != 0:
            finishTime1 = (float(self.totalSize) /
                           self.sizeComplete) * elapsedTime
        else:
            finishTime1 = (float(self.totalSize)) * elapsedTime

        if self.numComplete != 0:
            finishTime2 = (float(self.numTotal) /
                           self.numComplete) * elapsedTime
        else:
            finishTime2 = (float(self.numTotal)) * elapsedTime

        if self.filesComplete != 0:
            finishTime3 = (float(self.totalFiles) /
                           self.filesComplete) * elapsedTime
        else:
            finishTime3 = (float(self.totalFiles)) * elapsedTime

        finishTime = finishTime1
        # another alternate suggestion
        #	finishTime = math.sqrt(finishTime1 * finishTime2)

        remainingTime = finishTime - elapsedTime

        fractionComplete = float(self.sizeComplete) / float(self.totalSize)

        timeest = 1.4 * remainingTime / 60.0

        # average last 10 estimates
        self.estimateHistory.append(timeest)
        if len(self.estimateHistory) > 10:
            del self.estimateHistory[0]
        tavg = 0.0
        for testimate in self.estimateHistory:
            tavg += testimate

        timeest = tavg / float(len(self.estimateHistory))

        # here is strategy for time estimate
        #
        # 1) First 100 or so packages give us misleading estimates as things
        #    are not settled down. So no estimate until past 100 packages
        #
        # 2) Time estimate based on % of bytes installed is on about 30% too
        #    low overall. So we just bump our estimate to compensate
        #
        # 3) Lets only report time on 5 minute boundaries, and round up.
        #

        #	self.timeLog.write("%s %s %s %s %s %s %s %s %s %s %s %s\n" % (elapsedTime/60.0, (finishTime1-elapsedTime)/60.0, (finishTime2-elapsedTime)/60.0, (finishTime3-elapsedTime)/60.0, (finishTime-elapsedTime)/60.0, timeest, self.sizeComplete, self.totalSize, self.numComplete, self.numTotal, self.filesComplete, self.totalFiles, ))
        #	self.timeLog.flush()

        #	if (fractionComplete > 0.10):
        if self.numComplete > 100:
            if self.initialTimeEstimate is None:
                self.initialTimeEstimate = timeest
                log("Initial install time estimate = %s", timeest)

#	    log ("elapsed time, time est, remaining time =  %s %s", int(elapsedTime/60), timeest)

            if timeest < 10:
                timefactor = 2
            else:
                timefactor = 5
            str = _("Remaining time: %s minutes") % (
                (int(timeest / timefactor) + 1) * timefactor, )
            self.remainingTimeLabel.set_text(str)

        if (fractionComplete >= 1):
            log("Actual install time = %s", elapsedTime / 60.0)
            self.remainingTimeLabel.set_text("")

        self.totalProgress.set_fraction(fractionComplete)

        return
コード例 #10
0
ファイル: mieru.py プロジェクト: M4rtinK/mieru
  def __init__(self):
    # log start
    initTs = time.clock()
    self.startupTimeStamp = time.time()

    # parse startup arguments
    start = startup.Startup()
    args = start.args
    self.args = args
    self.originalCWD = originalCWD

    # restore the persistent options dictionary
    self.d = {}
    self.options = options.Options(self)
    # options value watching
    self.maxWatchId = 0
    self.watches = {}
    # history lock
    self.historyLock = RLock() # NOTE: not yet used

    # enable stats
    self.stats = stats.Stats(self)

    self.continuousReading = True

    # get the platform module
    self.platform = None

    # get the platform ID string
    platformId = "pc" # safe fallback
    if args.p is None:
      import platform_detection
      # platform detection
      result = platform_detection.getBestPlatformModuleId()
      if result:
        platformId = result
    else: # use the CLI provided value
      platformId = args.p

    if platformId:
      if platformId == "maemo5":
        import maemo5

        if args.u == "hildon": # enable app menu with Hildon gui
          self.platform = maemo5.Maemo5(self, GTK=True)
        else:
          self.platform = maemo5.Maemo5(self, GTK=False)
      elif platformId == "harmattan":
        import harmattan

        self.platform = harmattan.Harmattan(self)
      else:
        import pc

        self.platform = pc.PC(self)

    else:
      # no platform provided, decide based on selected GUI
      if args.u == "hildon":
        import maemo5

        self.platform = maemo5.Maemo5(self, GTK=True)
      elif args.u == "harmattan":
        import harmattan

        self.platform = harmattan.Harmattan(self)
      else:
        import pc

        self.platform = pc.PC(self)


    # create the GUI
    startTs1 = timer.start()

    # use CLI provided GUI module ID
    if args.u:
      self._loadGUIModule(args.u)
    else: # get GUI module id from the platform module
      ids = self.platform.getSupportedGUIModuleIds()
      if ids:
        guiModuleId = ids[0]
        print('preferred GUI ID from platform module: %s' % guiModuleId)
        self._loadGUIModule(guiModuleId)
      else:
        print("platform module error: list of supported GUI IDs is empty")

    timer.elapsed(startTs1, "GUI module import")

    #    # resize the viewport when window size changes
    #    self.gui.resizeNotify(self._resizeViewport)

    self.activeManga = None

    # check if a path was specified in the startup arguments
    if args.o is not None:
      try:
        print("loading manga from: %s" % args.o)
        self.setActiveManga(self.openManga(args.o, checkHistory=True))
        print('manga loaded')
      except Exception, e:
        print("loading manga from path: %s failed" % args.o)
        print(e)
コード例 #11
0
ファイル: mieru.py プロジェクト: funkycode/mieru
  def __init__(self):
    # log start
    initTs = time.clock()
    self.startupTimeStamp = time.time()

    # parse startup arguments
    start = startup.Startup()
    args = start.args
    self.args = args

    # restore the persistent options dictionary
    self.d = {}
    self.options = options.Options(self)
    # options value watching
    self.maxWatchId = 0
    self.watches = {}
    # history lock
    self.historyLock = RLock()

    # enable stats
    self.stats = stats.Stats(self)

    self.continuousReading = True

    initialSize = (800,480)


    # get the platform module
    self.platform = None

    if args.p:
      if args.p == "maemo5":
        import maemo5
        self.platform = maemo5.Maemo5(self, GTK=False)
      elif args.p == "harmattan":
        import harmattan
        self.platform = harmattan.Harmattan(self)
      else:
        import pc
        self.platform = pc.PC(self)

    else:
      # no platform provided, decide based on selected GUI
      if args.u == "hildon":
        import maemo5
        self.platform = maemo5.Maemo5(self)
      elif args.u == "harmattan":
        import harmattan
        self.platform = harmattan.Harmattan(self)
      else:
        import pc
        self.platform = pc.PC(self)


    # create the GUI
    startTs1 = timer.start()

    if args.u == "hildon":
      self.gui = gui.getGui(self, 'hildon', accel=True, size=initialSize)
    if args.u == "harmattan" or args.u=='QML':
      self.gui = gui.getGui(self, 'QML', accel=True, size=initialSize)
    else:
      self.gui = gui.getGui(self, 'GTK', accel=True, size=initialSize)

    timer.elapsed(startTs1, "GUI module import")

#    # resize the viewport when window size changes
#    self.gui.resizeNotify(self._resizeViewport)




    self.activeManga = None

    # check if a path was specified in the startup arguments
    if args.o is not None:
      try:
        print("loading manga from: %s" % args.o)
        self.setActiveManga(self.openManga(args.o))
        print('manga loaded')
      except Exception, e:
        print("loading manga from path: %s failed" % args.o)
        print(e)