Advertisement
Guest User

Untitled

a guest
May 5th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.80 KB | None | 0 0
  1. Index: interfaces/Plush/language/us-en.txt
  2. ===================================================================
  3. --- interfaces/Plush/language/us-en.txt (revision 3079)
  4. +++ interfaces/Plush/language/us-en.txt (working copy)
  5. @@ -4,6 +4,7 @@
  6.  
  7.  # Menu
  8.  maxSpeed          Max Speed
  9. +maxbytes           Max Bytes
  10.  options           Plush Options
  11.  refreshRate       Refresh Rate
  12.  confirmDeleteQueue Confirm Queue Deletions
  13. Index: interfaces/Plush/templates/config_general.tmpl
  14. ===================================================================
  15. --- interfaces/Plush/templates/config_general.tmpl  (revision 3079)
  16. +++ interfaces/Plush/templates/config_general.tmpl  (working copy)
  17. @@ -133,6 +133,11 @@
  18.      <input type="text" name="bandwidth_limit" value="$bandwidth_limit" size=8 />
  19.  
  20.      <br/><br/>
  21. +    <strong>$T('opt-byte_limit'):</strong><br/>
  22. +    <small>$T('explain-byte_limit')</small><br/>
  23. +    <input type="text" name="byte_limit" value="$byte_limit" size=8 />
  24. +
  25. +    <br/><br/>
  26.      <strong>$T('opt-cache_limitstr'):</strong><br/>
  27.      <small>$T('explain-cache_limitstr')</small><br/>
  28.      <input type="text" name="cache_limit" value="$cache_limit" size=8 />
  29. Index: language/us-en.txt
  30. ===================================================================
  31. --- language/us-en.txt  (revision 3079)
  32. +++ language/us-en.txt  (working copy)
  33. @@ -113,6 +113,7 @@
  34.  hibernatePc       Hibernate PC
  35.  shutdownSab       Shutdown SABnzbd
  36.  speedLimit        Speed Limit
  37. +bytelimit         Byte Limit
  38.  pauseFor          Pause for
  39.  mode              Processing
  40.  order             Order
  41. @@ -214,6 +215,9 @@
  42.  explain-rss_rate      Checking interval (in minutes, at least 15).
  43.  opt-bandwidth_limit   Download Speed Limit
  44.  explain-bandwidth_limit Download rate limit (in KB/s - kilobytes per second).
  45. +opt-byte_limit        Byte Limit
  46. +explain-byte_limit    Download byte limit before connection reset (in KB/s - kilobytes). \n\
  47. +                      <i>Helpful when throughput is increased durring initial download session.</i>
  48.  opt-cache_limitstr    Article Cache Limit
  49.  explain-cache_limitstr Cache articles in memory to reduce disk access.\n\
  50.                        <i>In bytes, optionally follow with K,M,G. For example: "64M" or "128M"</i>
  51. Index: sabnzbd/cfg.py
  52. ===================================================================
  53. --- sabnzbd/cfg.py  (revision 3079)
  54. +++ sabnzbd/cfg.py  (working copy)
  55. @@ -150,6 +150,9 @@
  56.  USERNAME = OptionStr('misc', 'username')
  57.  PASSWORD = OptionPassword('misc', 'password')
  58.  BANDWIDTH_LIMIT = OptionNumber('misc', 'bandwidth_limit', 0)
  59. +# BYTE_LIMIT Test Code - Begin
  60. +BYTE_LIMIT = OptionNumber('misc', 'byte_limit', 0)
  61. +# BYTE_LIMIT Test Code - End
  62.  REFRESH_RATE = OptionNumber('misc', 'refresh_rate', 0)
  63.  RSS_RATE = OptionNumber('misc', 'rss_rate', 60, 15, 24*60)
  64.  CACHE_LIMIT = OptionStr('misc', 'cache_limit')
  65. Index: sabnzbd/downloader.py
  66. ===================================================================
  67. --- sabnzbd/downloader.py   (revision 3079)
  68. +++ sabnzbd/downloader.py   (working copy)
  69. @@ -135,6 +135,14 @@
  70.      if __DOWNLOADER: __DOWNLOADER.limit_speed(int(value))
  71.      logging.info("Bandwidth limit set to %s", value)
  72.  
  73. +# Byte_Limit - Test Code - Begin
  74. +@synchronized_CV
  75. +def limit_byte(value):
  76. +    global __DOWNLOADER
  77. +    if __DOWNLOADER: __DOWNLOADER.limit_byte(int(value))
  78. +    logging.info("Byte limit set to %s", value)
  79. +# Byte_Limit - Test Code - End
  80. +
  81.  def update_server(oldserver, newserver):
  82.      global __DOWNLOADER
  83.      try:
  84. @@ -157,6 +165,12 @@
  85.      global __DOWNLOADER
  86.      if __DOWNLOADER: return __DOWNLOADER.get_limit()
  87.  
  88. +# Byte_Limit - Test Code - Begin
  89. +def get_byte_limit():
  90. +    global __DOWNLOADER
  91. +    if __DOWNLOADER: return __DOWNLOADER.get_byte_limit()
  92. +# Byte Limit - Test Code - End
  93. +
  94.  def disconnect():
  95.      global __DOWNLOADER
  96.      if __DOWNLOADER: __DOWNLOADER.disconnect()
  97. @@ -233,6 +247,11 @@
  98.          self.bandwidth_limit = cfg.BANDWIDTH_LIMIT.get()
  99.          cfg.BANDWIDTH_LIMIT.callback(self.speed_set)
  100.  
  101. +        #Byte_Limit Test Code - Begin
  102. +        self.byte_limit = cfg.BYTE_LIMIT.get() * 1024
  103. +        cfg.BYTE_LIMIT.callback(self.byte_limit_set)
  104. +        #Byte_Limit Test Code - End
  105. +
  106.          # Used for reducing speed
  107.          self.delayed = False
  108.  
  109. @@ -348,6 +367,17 @@
  110.      def speed_set(self):
  111.          self.bandwidth_limit = cfg.BANDWIDTH_LIMIT.get()
  112.  
  113. +    # Byte_Limit Test Code - Begin
  114. +    def limit_bytes(self, value):
  115. +        self.byte_limit = value
  116. +
  117. +    def get_byte_limit(self):
  118. +        return self.byte_limit
  119. +
  120. +    def byte_limit_set(self):
  121. +        self.byte_limit = cfg.BYTE_LIMIT.get() * 1024
  122. +    # Byte_Limit Test Code - End
  123. +
  124.      def is_paused(self):
  125.          if not self.paused:
  126.              return False
  127. @@ -519,6 +549,20 @@
  128.                      self.__reset_nw(nw, "server closed connection", warn=False, wait=False)
  129.                      continue
  130.  
  131. +                # Begin Thread Byte Limit Code
  132. +                if self.byte_limit > 0:
  133. +                    bpsmeter.method.update(bytes)
  134. +                    try:
  135. +                        bytecount = bytecount + bytes
  136. +                        # logging.info("Byte Limit: %s, Byte Count: %s, Bytes: %s, NW: %s", self.byte_limit, bytecount, bytes, nw)
  137. +                        if bytecount > self.byte_limit:
  138. +                            self.__reset_nw(nw, "byte limit reached for thread", warn=False, wait=False, destroy=False)
  139. +                            bytecount = 0
  140. +                            continue
  141. +                    except NameError:
  142. +                        bytecount = 0
  143. +                # End Thread Byte Limit Code
  144. +
  145.                  else:
  146.                      if self.bandwidth_limit:
  147.                          bps = bpsmeter.method.get_bps()
  148. Index: sabnzbd/interface.py
  149. ===================================================================
  150. --- sabnzbd/interface.py    (revision 3079)
  151. +++ sabnzbd/interface.py    (working copy)
  152. @@ -1683,6 +1683,9 @@
  153.          conf['username'] = cfg.USERNAME.get()
  154.          conf['password'] = cfg.PASSWORD.get_stars()
  155.          conf['bandwidth_limit'] = cfg.BANDWIDTH_LIMIT.get()
  156. +# Byte_Limit Test Code - Begin
  157. +        conf['byte_limit'] = cfg.BYTE_LIMIT.get()
  158. +# Byte_Limit Test Code - End
  159.          conf['refresh_rate'] = cfg.REFRESH_RATE.get()
  160.          conf['rss_rate'] = cfg.RSS_RATE.get()
  161.          conf['cache_limit'] = cfg.CACHE_LIMIT.get()
  162. @@ -1739,6 +1742,13 @@
  163.              bandwidth_limit = IntConv(bandwidth_limit)
  164.              cfg.BANDWIDTH_LIMIT.set(bandwidth_limit)
  165.  
  166. +# Byte_Limit Test Code - Begin
  167. +        byte_limit = kwargs.get('byte_limit')
  168. +        if byte_limit != None:
  169. +            byte_limit = IntConv(byte_limit)
  170. +            cfg.BYTE_LIMIT.set(byte_limit)
  171. +# Byte_Limit Test Code - End
  172. +
  173.          config.save_config()
  174.  
  175.          # Update CherryPy authentication
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement