from bfs.bfs10143.bfs10147 import LicenseInvalid
from helium.bfs10143.bfs10147 import bfs10201
from logging import getLogger
from random import Random
class License(object):
  def bfs10530(self, bfs11324):
    bfs11326 = self.bfs11330(bfs11324)
    if (not bfs11326):
      raise LicenseInvalid(bfs11326.message)


  def bfs11330(self, bfs11327):
    raise NotImplementedError()


class bfs11331(License):
  def bfs11330(self, bfs11332):
    return bfs11333(True, 'Development license (eternally valid).')


class bfs11335(License):
  bfs11334 = 0
  bfs11336 = 1
  bfs11337 = 'dstn;heaf402321'
  bfs11341 = 'Unfortunately, your Helium license has expired. Please obtain a new one from\n\thttp://heliumhq.com'
  bfs11340 = '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'
  bfs11342 = 'Unfortunately, your Helium license is invalid. Please obtain a new one from\n\thttp://heliumhq.com'
  def __init__(self, bfs11343, bfs10227, bfs11344, bfs11346, seed=None):
    self.bfs10230 = bfs11343.read()
    self.bfs11343 = bfs11343
    self.bfs10227 = bfs10227
    self.bfs11344 = bfs11344
    self.bfs11346 = bfs11346
    self.random = Random(seed)
    self.bfs11345 = None

  def bfs11330(self, bfs11347):
    if (self.bfs11345 is None):
      self.bfs11345 = self.bfs11350(bfs11347)

    return self.bfs11345

  def bfs11350(self, bfs11351):
    if self.bfs11352():
      return bfs11333(False, self.bfs11341)

    if self.bfs11353():
      return self.bfs11355(bfs11351)

    return bfs11333(True, ('Licensed to ' + self.bfs10230.bfs10233))

  def bfs11352(self):
    bfs11354 = self.bfs11344.bfs11356()
    return self.bfs10230.bfs11167(bfs11354)

  def bfs11353(self):
    if self.bfs10230.bfs10231:
      if (not self.bfs10230.bfs11171()):
        return True

      if self.bfs11360():
        return True


    if self.bfs10230.bfs11157:
      return (self.bfs11346 or (self.random.random() <= 0.05))

    return False

  def bfs11360(self):
    bfs11357 = self.bfs10227.bfs10232()
    bfs11361 = self.bfs10230.bfs11163
    return (bfs11357 != bfs11361)

  def bfs11355(self, bfs11362):
    bfs11363 = bfs11362.bfs10224(self.bfs10230, self.bfs10227)
    bfs10231 = self.bfs10230.bfs10231
    if (not bfs11363):
      if (bfs10231 and self.bfs11360()):
        return bfs11333(False, self.bfs11340)
      else:
        return bfs11333(False, self.bfs11342)

    else:
      if (bfs11363 == self.bfs11337):
        bfs11365 = (not bfs10231)
      else:
        if (not bfs10231):
          bfs11365 = False
        else:
          try:
            self.bfs10230.bfs11173(bfs11363)
          except ValueError, bfs11364:
            raise bfs10201(bfs11364)

          bfs11365 = (not self.bfs11360())
          if bfs11365:
            try:
              self.bfs11343.write(self.bfs10230)
            except (OSError, IOError):
              getLogger(__name__).warn('Could not write to license file %s.', self.bfs11343.file_path, exc_info=True)




      if bfs11365:
        message = ('Licensed to ' + self.bfs10230.bfs10233)
      else:
        message = self.bfs11342


    return bfs11333(bfs11365, message)


class bfs11333(object):
  def __init__(self, bfs11330, message):
    self.bfs11330 = bfs11330
    self.message = message

  def __nonzero__(self):
    return self.bfs11330


