from bfs.bfs10143.bfs10147 import LicenseInvalid
from helium.bfs10143.bfs10147 import bfs10201
from logging import getLogger
from random import Random
class License(object):
  def bfs10523(self, bfs11317):
    bfs11320 = self.bfs11321(bfs11317)
    if (not bfs11320):
      raise LicenseInvalid(bfs11320.message)


  def bfs11321(self, bfs11322):
    raise NotImplementedError()


class bfs11323(License):
  def bfs11321(self, bfs11325):
    return bfs11324(True, 'Development license (eternally valid).')


class bfs11326(License):
  bfs11330 = 0
  bfs11327 = 1
  bfs11331 = 'dstn;heaf402321'
  bfs11332 = 'Unfortunately, your Helium license has expired. Please obtain a new one from\n\thttp://heliumhq.com'
  bfs11333 = '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'
  bfs11335 = 'Unfortunately, your Helium license is invalid. Please obtain a new one from\n\thttp://heliumhq.com'
  def __init__(self, bfs11334, bfs11250, bfs11336, bfs11337, seed=None):
    self.bfs11146 = bfs11334.read()
    self.bfs11334 = bfs11334
    self.bfs11250 = bfs11250
    self.bfs11336 = bfs11336
    self.bfs11337 = bfs11337
    self.random = Random(seed)
    self.bfs11341 = None

  def bfs11321(self, bfs11340):
    if (self.bfs11341 is None):
      self.bfs11341 = self.bfs11342(bfs11340)

    return self.bfs11341

  def bfs11342(self, bfs11343):
    if self.bfs11344():
      return bfs11324(False, self.bfs11332)

    if self.bfs11346():
      return self.bfs11345(bfs11343)

    return bfs11324(True, ('Licensed to ' + self.bfs11146.bfs10233))

  def bfs11344(self):
    bfs11347 = self.bfs11336.bfs11350()
    return self.bfs11146.bfs11162(bfs11347)

  def bfs11346(self):
    if self.bfs11146.bfs10231:
      if (not self.bfs11146.bfs11163()):
        return True

      if self.bfs11351():
        return True


    if self.bfs11146.is_online:
      return (self.bfs11337 or (self.random.random() <= 0.05))

    return False

  def bfs11351(self):
    bfs11352 = self.bfs11250.bfs10232()
    bfs11353 = self.bfs11146.bfs11155
    return (bfs11352 != bfs11353)

  def bfs11345(self, bfs11355):
    bfs11354 = bfs11355.bfs10224(self.bfs11146, self.bfs11250)
    bfs10231 = self.bfs11146.bfs10231
    if (not bfs11354):
      if (bfs10231 and self.bfs11351()):
        return bfs11324(False, self.bfs11333)
      else:
        return bfs11324(False, self.bfs11335)

    else:
      if (bfs11354 == self.bfs11331):
        bfs11356 = (not bfs10231)
      else:
        if (not bfs10231):
          bfs11356 = False
        else:
          try:
            self.bfs11146.bfs11165(bfs11354)
          except ValueError as bfs11360:
            raise bfs10201(bfs11360)

          bfs11356 = (not self.bfs11351())
          if bfs11356:
            try:
              self.bfs11334.write(self.bfs11146)
            except (OSError, IOError):
              getLogger(__name__).warn('Could not write to license file %s.', self.bfs11334.file_path, exc_info=True)




      if bfs11356:
        message = ('Licensed to ' + self.bfs11146.bfs10233)
      else:
        message = self.bfs11335


    return bfs11324(bfs11356, message)


class bfs11324(object):
  def __init__(self, bfs11321, message):
    self.bfs11321 = bfs11321
    self.message = message

  def __bool__(self):
    return self.bfs11321


