from bfs.bfs10110.bfs10112 import LicenseInvalid
from helium.bfs10110.bfs10112 import bfs10145
from logging import getLogger
from random import Random
class License(object):
  def bfs10452(self, bfs11231):
    bfs11230 = self.bfs11232(bfs11231)
    if (not bfs11230):
      raise LicenseInvalid(bfs11230.message)


  def bfs11232(self, bfs11234):
    raise NotImplementedError()


class bfs11233(License):
  def bfs11232(self, bfs11235):
    return bfs11236(True, 'Development license (eternally valid).')


class bfs11237(License):
  bfs11241 = 0
  bfs11240 = 1
  bfs11242 = 'dstn;heaf402321'
  bfs11243 = 'Unfortunately, your Helium license has expired. Please obtain a new one from\n\thttp://heliumhq.com'
  bfs11244 = 'Unfortunately, your Helium license is already in use on another computer. To use it on this machine, please contact support at\n\thttp://heliumhq.com'
  bfs11246 = 'Unfortunately, your Helium license is invalid. Please obtain a new one from\n\thttp://heliumhq.com'
  def __init__(self, bfs11245, bfs11160, bfs11247, bfs11250, seed=None):
    self.bfs11055 = bfs11245.read()
    self.bfs11245 = bfs11245
    self.bfs11160 = bfs11160
    self.bfs11247 = bfs11247
    self.bfs11250 = bfs11250
    self.random = Random(seed)
    self.bfs11251 = None

  def bfs11232(self, bfs11253):
    if (self.bfs11251 is None):
      self.bfs11251 = self.bfs11252(bfs11253)

    return self.bfs11251

  def bfs11252(self, bfs11254):
    if self.bfs11256():
      return bfs11236(False, self.bfs11243)

    if self.bfs11255():
      return self.bfs11257(bfs11254)

    return bfs11236(True, ('Licensed to ' + self.bfs11055.bfs10166))

  def bfs11256(self):
    bfs11261 = self.bfs11247.bfs11260()
    return self.bfs11055.bfs11072(bfs11261)

  def bfs11255(self):
    if self.bfs11055.bfs10162:
      if (not self.bfs11055.bfs11074()):
        return True

      if self.bfs11262():
        return True


    if self.bfs11055.is_online:
      return (self.bfs11250 or (self.random.random() <= 0.05))

    return False

  def bfs11262(self):
    bfs11263 = self.bfs11160.bfs10164()
    bfs11265 = self.bfs11055.bfs11067
    return (bfs11263 != bfs11265)

  def bfs11257(self, bfs11264):
    bfs11266 = bfs11264.bfs10156(self.bfs11055, self.bfs11160)
    bfs10162 = self.bfs11055.bfs10162
    if (not bfs11266):
      if (bfs10162 and self.bfs11262()):
        return bfs11236(False, self.bfs11244)
      else:
        return bfs11236(False, self.bfs11246)

    else:
      if (bfs11266 == self.bfs11242):
        bfs11267 = (not bfs10162)
      else:
        if (not bfs10162):
          bfs11267 = False
        else:
          try:
            self.bfs11055.bfs11075(bfs11266)
          except ValueError as bfs11270:
            raise bfs10145(bfs11270)

          bfs11267 = (not self.bfs11262())
          if bfs11267:
            try:
              self.bfs11245.write(self.bfs11055)
            except (OSError, IOError):
              getLogger(__name__).warn('Could not write to license file %s.', self.bfs11245.file_path, exc_info=True)




      if bfs11267:
        message = ('Licensed to ' + self.bfs11055.bfs10166)
      else:
        message = self.bfs11246


    return bfs11236(bfs11267, message)


class bfs11236(object):
  def __init__(self, bfs11232, message):
    self.bfs11232 = bfs11232
    self.message = message

  def __bool__(self):
    return self.bfs11232


