Esempio n. 1
0
    def __init__(self, config):
        BaseHandler.__init__(self, 'Balancer')

        self.required_attrs = ['request_weight']

        self.max_dataset_size = config.max_dataset_size * 1.e+12
        self.target_reasons = dict(config.target_reasons)
Esempio n. 2
0
    def __init__(self, config):
        BaseHandler.__init__(self, 'Balancer')

        self.max_dataset_size = config.get('max_dataset_size', 0) * 1.e+12
        self.max_cycle_volume = config.get('max_cycle_volume', 0) * 1.e+12
        self.detoxhistory = DetoxHistoryBase(config.get('detox_history', None))
        self.target_reasons = dict(config.target_reasons)
Esempio n. 3
0
    def get(self, url):
        BaseHandler.initFromRequest(self, self.request)
        if not url or len(url) < 1:
            return
        
        #if len(url) > 0:
        #    path = os.path.join(os.path.dirname(__file__), 'web', url)
        #else:
        publisherUrl = self.request.host + "/wiki/" + url
        if publisherUrl[-1] != "/":
            publisherUrl += "/"
        #publisherUrl = publisherUrl.lower()
        items = BaseHandler.getOrderedItems(self,
                                            publisherUrl,
                                            model.getDefaultFilter()) #NO_VIEWER self.viewer.filter)

        #publisherLinks = model.getItems(publisherUrl)
        if len(items) < 1:
            self.copyWikiLinks(url)
            
        path = os.path.join(os.path.dirname(__file__), 'web', 'wiki_template.html')
        out = ''
        try:
          out = template.render(path, {})
          self.response.headers["Access-Control-Allow-Origin"] = '*'
        except Exception:
          logging.warning('createWikiHandler: %s' % sys.exc_info()[1])
          out = ''
        self.response.out.write(out)
Esempio n. 4
0
    def __init__(self, config):
        BaseHandler.__init__(self, 'Balancer')

        self.max_dataset_size = config.get('max_dataset_size', 0) * 1.e+12
        self.max_cycle_volume = config.get('max_cycle_volume', 0) * 1.e+12
        self.detoxhistory = DetoxHistoryBase(config.get('detox_history', None))
        self.target_reasons = dict(config.target_reasons)
    def __init__(self, debug=False):
        BaseHandler.__init__(self, debug)
        self.current={}
        self.sm= {
                   ("se", "lfm"):                    "do_skip"
        
                  ,("se", "recenttracks"):           "do_recenttracks"
                  ,("en", "recenttracks"):           "do_skip"
                  
                  ,("se", "track"):                  "do_begin_track"
                  ,("en", "track"):                  "do_end_track"
                  
                  ,("se", "artist"):                 ("do_grab_el_attrs","artist")
                  ,("se", "artist", "en", "artist"): ("do_grab_el_data", "artist")
                  
                  ,("se", "album"):                  ("do_grab_el_attrs", "album")
                  ,("se", "album", "en", "album"):   ("do_grab_el_data", "album")

                  ,("se", "name"):                   ("do_grab_el_attrs", "name")
                  ,("se", "name", "en", "name"):     ("do_grab_el_data", "name")

                  ,("se", "mbid"):                   "do_noop"
                  ,("se", "mbid", "en", "mbid"):     ("do_grab_el_data", "mbid")

                  ,("se", "url"):                    "do_noop"
                  ,("se", "url", "en", "url"):       ("do_grab_el_data", "url")

                  ,("se", "date"):                   ("do_grab_el_attrs", "date")
                  ,("se", "date", "en", "date"):     ("do_grab_el_data", "date")
                  
                  }
Esempio n. 6
0
 def get(self):
     if(self.current_user == None or self.current_user.decode() != "2019"):
         BaseHandler.get(self)
     else:
         link_command("exit")
         BaseHandler.get(self)
     
     #yield self.render('manage.html', title = 'manage', user = self.current_user)
Esempio n. 7
0
  def get(self):
    BaseHandler.initialize(self)

    if not self.authenticate(author=True):
      return

    path = self.data_liberation_path()
    tornado.web.StaticFileHandler.get(self, path)
Esempio n. 8
0
    def __init__(self, config):
        BaseHandler.__init__(self, 'Popularity')
        self.required_attrs = ['request_weight']

        self.source_groups = set(config.source_groups)
        self.max_dataset_size = config.max_dataset_size * 1.e+12
        self.max_replication = config.max_replication
        self.request_to_replica_threshold = config.request_to_replica_threshold

        self._datasets = []
Esempio n. 9
0
    def __init__(self, config):
        BaseHandler.__init__(self, 'Popularity')
        self.required_attrs = ['request_weight']

        self.source_groups = set(config.source_groups)
        self.max_dataset_size = config.max_dataset_size * 1.e+12
        self.max_replication = config.max_replication
        self.request_to_replica_threshold = config.request_to_replica_threshold

        self._datasets = []
Esempio n. 10
0
    def __init__(self, config):
        BaseHandler.__init__(self, 'Enforcer')
        
        if type(config.enforcer) is str:
            # A path to the common enforcer configuration
            enforcer_config = Configuration(config.enforcer)
        else:
            enforcer_config = config.enforcer

        self.interface = EnforcerInterface(enforcer_config)
Esempio n. 11
0
    def __init__(self, config):
        BaseHandler.__init__(self, 'Enforcer')

        if type(config.enforcer) is str:
            # A path to the common enforcer configuration
            enforcer_config = Configuration(config.enforcer)
        else:
            enforcer_config = config.enforcer

        self.interface = EnforcerInterface(enforcer_config)
Esempio n. 12
0
 def __init__(self, debug=False):
     BaseHandler.__init__(self, debug)
     self.currentTag = {}
     self.sm = {
         ("se", "lfm"): "do_skip",
         ("se", "track"): "do_begin_track",
         ("en", "track"): "do_end_track",
         ("se", "id"): "do_noop",
         ("se", "id", "en", "id"): "do_grab_data",
         ("se", "name"): "do_noop",
         ("se", "name", "en", "name"): "do_grab_data",
         ("se", "url"): "do_noop",
         ("se", "url", "en", "url"): "do_grab_data",
         ("se", "playcount"): "do_noop",
         ("se", "playcount", "en", "playcount"): "do_grab_data",
         ("se", "userplaycount"): "do_noop",
         ("se", "userplaycount", "en", "userplaycount"): "do_grab_data",
         ("se", "userloved"): "do_noop",
         ("se", "userloved", "en", "userloved"): "do_grab_data",
         ("se", "mbid"): "do_noop",
         ("se", "mbid", "en", "mbid"): "do_grab_data"
         ## ARTIST
         ,
         ("se", "artist"): "do_noop",
         ("se", "artist", "en", "artist"): "do_skip",
         ("se", "artist", "se", "name"): "do_noop",
         ("se", "artist", "se", "name", "en", "name"): ("do_grab_artist_params", "artist.name"),
         ("se", "artist", "se", "mbid"): "do_noop",
         ("se", "artist", "se", "mbid", "en", "mbid"): ("do_grab_artist_params", "artist.mbid"),
         ("se", "artist", "se", "url"): "do_noop",
         ("se", "artist", "se", "url", "en", "url"): ("do_grab_artist_params", "artist.url")
         ## ALBUM
         ,
         ("se", "album"): "do_noop",
         ("se", "album", "en", "album"): "do_skip",
         ("se", "album", "se", "artist"): "do_noop",
         ("se", "album", "se", "artist", "en", "artist"): ("do_grab_album_params", "album.artist"),
         ("se", "album", "se", "title"): "do_noop",
         ("se", "album", "se", "title", "en", "title"): ("do_grab_album_params", "album.title"),
         ("se", "album", "se", "mbid"): "do_noop",
         ("se", "album", "se", "mbid", "en", "mbid"): ("do_grab_album_params", "album.mbid"),
         ("se", "album", "se", "url"): "do_noop",
         ("se", "album", "se", "url", "en", "url"): ("do_grab_album_params", "album.url")
         ## TAGS
         ,
         ("se", "toptags"): "do_skip",
         ("se", "tag"): "do_commit_tag",
         ("se", u"tag", "en", u"tag"): "do_skip",
         ("se", "tag", "se", "name"): "do_noop",
         ("se", "tag", "se", "name", "en", "name"): ("do_grab_tag_params", "tag.name"),
         ("se", "tag", "se", "url"): "do_noop",
         ("se", "tag", "se", "url", "en", "url"): ("do_grab_tag_params", "tag.url"),
     }
Esempio n. 13
0
    def __init__(self, config):
        BaseHandler.__init__(self, 'Popularity')
        self.required_attrs = ['request_weight']

        self.source_groups = set(config.source_groups)
        self.max_dataset_size = config.max_dataset_size * 1.e+12
        self.max_replication = config.max_replication
        self.request_to_replica_threshold = config.request_to_replica_threshold
        try:
            self.condition = Condition(config.condition, replica_variables)
        except:
            self.condition = None

        self._datasets = []
Esempio n. 14
0
 def post(self):
   try:
     BaseHandler.initFromRequest(self, self.request)
     orderedItems = BaseHandler.getOrderedItems(self,
                                                self.getParam('publisherUrl'),
                                                model.getDefaultFilter()) 
     if self.client.numItems < len(orderedItems):
       orderedItems = orderedItems[0: self.client.numItems]
     self.common_response.setItems(orderedItems, response.ItemInfo.WITH_PRICE)
     if self.client.numItems - len(orderedItems) > 0:
       BaseHandler.setDefaultItems(self, self.client.numItems - len(orderedItems))
   except Exception:
     BaseHandler.logException(self)
   BaseHandler.writeResponse(self)
Esempio n. 15
0
 def post(self):
   try:
     BaseHandler.initFromRequest(self, self.request)
     paidItems = BaseHandler.getPaidItems(self, self.getParam('publisherUrl'))                                            
     self.common_response.setItems(paidItems, response.ItemInfo.WITH_PRICE)
   except Exception:
     BaseHandler.logException(self)
   BaseHandler.writeResponse(self)
Esempio n. 16
0
  def get(self, path):
    BaseHandler.initialize(self)

    try:
      if not self.authenticate(private_resource=self.request.uri,
          auto_login=False):
        # 401, need to login
        self.set_status(401)
        self.prevent_caching()
        tornado.web.StaticFileHandler.get(self, "401.png")
        return
    except tornado.web.HTTPError as ex:
      # 403, forbidden
      self.set_status(403)
      self.prevent_caching()
      tornado.web.StaticFileHandler.get(self, "403.png")
      return

    # ok!
    tornado.web.StaticFileHandler.get(self, path)
Esempio n. 17
0
    def get(self, path):
        BaseHandler.initialize(self)

        try:
            if not self.authenticate(private_resource=self.request.uri,
                                     auto_login=False):
                # 401, need to login
                self.set_status(401)
                self.prevent_caching()
                tornado.web.StaticFileHandler.get(self, "401.png")
                return
        except tornado.web.HTTPError as ex:
            # 403, forbidden
            self.set_status(403)
            self.prevent_caching()
            tornado.web.StaticFileHandler.get(self, "403.png")
            return

        # ok!
        tornado.web.StaticFileHandler.get(self, path)
Esempio n. 18
0
 def post(self):
   try:
     BaseHandler.initFromRequest(self, self.request)
     orderedItems = BaseHandler.getOrderedItems(self,
                                                self.getParam('publisherUrl'),
                                                model.getDefaultFilter())
     self.common_response.setItems(orderedItems, response.ItemInfo.SHORT)
   except Exception:
     BaseHandler.logException(self)
   BaseHandler.writeResponse(self)
Esempio n. 19
0
 def post(self):
   try:
     BaseHandler.initFromRequest(self, self.request)
     itemUpdates = self.getParam('interactions').split(',')
     for update in itemUpdates:
         itemWithUpdate = update.split(':')
         itemId = int(itemWithUpdate[0])
         statType = int(itemWithUpdate[1])
         spot = int(itemWithUpdate[2])
         BaseHandler.updateItem(self, self.getParam('publisherUrl'),
                                itemId=itemId, statType=statType, spot=spot)
   except Exception:
     BaseHandler.logException(self)
   BaseHandler.writeResponse(self)
Esempio n. 20
0
 def post(self):
   try:
     BaseHandler.initFromRequest(self, self.request)
     # TODO: assert https
     item = BaseHandler.getItem(self, self.getParam('itemId'))
     paymentConfig = model.getPaymentConfig()
     if item and self._verifyTransaction(item, paymentConfig.test_mode):  
       price = int(self.getParam('price'))
       item.updatePrice(price, self.getParam('email'))
       item.put()
       publisherSite = model.getPublisherSite(item.publisherUrl)
       db.run_in_transaction(updatePublisherPrice_, publisherSite.key(), price)
       itemList.refreshCacheForDefaultOrderedItems(item.publisherUrl)
       logging.info('Number of price updates : %d' % len(item.payments))
       logging.info('Last price update : %s' % str(item.payments[len(item.payments)-1]))
       if paymentConfig.send_email:
         BaseHandler.sendConfirmationEmail(self, self.getParam('email'), self.getParam('price'), item)                                   
     self.common_response.setItems([item], response.ItemInfo.WITH_PRICE)
   except Exception:
     BaseHandler.logException(self)
   BaseHandler.writeResponse(self)
Esempio n. 21
0
 def post(self):
   try:
     BaseHandler.initFromRequest(self, self.request)
     #publisherUrl is space delimited list of publishers
     publishers = self.getParam('publisherUrl').split(" ")
     publishersWithStats = []
     for publisher in publishers:
         publishersWithStats.append(model.getPublisherSite(publisher)) 
     self.common_response.setPublisherSites(publishersWithStats)
   except Exception:
     BaseHandler.logException(self)
   BaseHandler.writeResponse(self)
Esempio n. 22
0
 def post(self):
   try:
     BaseHandler.initFromRequest(self, self.request)
     #spot is space delimited list of spots
     spots = self.getParam('spot').split(" ")
     spotsWithStats = []
     for spot in spots:
         spotsWithStats.append(model.getSpot(self.getParam('publisherUrl'), int(spot))) 
     self.common_response.setSpots(spotsWithStats)
   except Exception:
     BaseHandler.logException(self)
   BaseHandler.writeResponse(self)
Esempio n. 23
0
 def post(self):
   try:
     BaseHandler.initFromRequest(self, self.request)
     #itemId is space delimited list of itemIds
     itemIds = self.getParam('itemId').split(" ")
     itemsWithStats = []
     for itemId in itemIds:
         itemsWithStats.append(BaseHandler.getItem(self, itemId))
     itemInfoType = response.ItemInfo.FULL;
     s = self.getParam('infoType');
     if len(s) and int(s) >= response.ItemInfo.SHORT and int(s) <= response.ItemInfo.FULL: 
       itemInfoType = int(s)
     logging.info('getItemStats for %s, infotype = %s->%d' % (self.getParam('itemId'), s, itemInfoType))
     self.common_response.setItems(itemsWithStats, itemInfoType)
   except Exception:
     BaseHandler.logException(self)
   BaseHandler.writeResponse(self)
Esempio n. 24
0
 def post(self):
     try:
       BaseHandler.initFromRequest(self, self.request)
       logging.info('email %s', self.getParam('email'))
       item = model.Item()
       item.publisherUrl = self.getParam('publisherUrl')
       item.url = self.getParam('url')
       item.thumbnailUrl = self.getParam('thumbnailUrl')
       item.title = self.getParam('title').replace('%u', '\\u').decode('unicode-escape')
       item.description = self.getParam('description').replace('%u', '\\u').decode('unicode-escape')
       item.price = 0
       item.email = self.getParam('email')
       item.put()
       itemList.refreshCacheForDefaultOrderedItems(item.publisherUrl)
       self.common_response.setItems([item], response.ItemInfo.SHORT)
     except Exception:
       BaseHandler.logException(self)
     BaseHandler.writeResponse(self)
Esempio n. 25
0
	def initialize(self, *a, **kw):
		BaseHandler.initialize(self, *a, **kw)
		self.error_code = None
Esempio n. 26
0
 def render(self, template_name, **named_params):
     account_username = self.account.username if self.account else None
     BaseHandler.render(self,
                        template_name,
                        account_username=account_username,
                        **named_params)
Esempio n. 27
0
 def get(self):
     BaseHandler.get(self)
Esempio n. 28
0
  def get(self):
    BaseHandler.initialize(self)

    increase_count(self)

    tornado.web.StaticFileHandler.get(self, 'img/pixel.gif')
Esempio n. 29
0
 def initialize(self, *params, **named_params):
     BaseHandler.initialize(self, *params, **named_params)
     self.account = self.get_logged_in_account()
Esempio n. 30
0
 def __init__(self):
     BaseHandler.__init__(self, 'Direct')
     self._mysql = MySQL(**config.registry.db_params)
Esempio n. 31
0
 def __init__(self, config):
     BaseHandler.__init__(self, 'GroupReassigner')
     
     self.from_groups = list(config.from_groups)
Esempio n. 32
0
    def get(self):
        BaseHandler.initialize(self)

        increase_count(self)

        tornado.web.StaticFileHandler.get(self, 'img/pixel.gif')
Esempio n. 33
0
 def render(self, template_name, **named_params):
     account_username = self.account.username if self.account else None
     BaseHandler.render(self, template_name, account_username = account_username, **named_params)
Esempio n. 34
0
 def post(self):
     BaseHandler.initFromRequest(self, self.request)
     logging.error('Client Error for %s \n%s' % (self.getParam('publisherUrl'), self.getParam('stack')));
Esempio n. 35
0
 def __init__(self, config):
     BaseHandler.__init__(self, 'Undertaker')
Esempio n. 36
0
    def __init__(self, config):
        BaseHandler.__init__(self, 'Undertaker')

        self.manual_evacuation_sites = list(config.get('additional_sites', []))
        self.detoxhistory = DetoxHistoryBase(config.get('detox_history', None))
Esempio n. 37
0
 def initialize(self, *params, **named_params):
     BaseHandler.initialize(self, *params, **named_params)
     self.account = self.get_logged_in_account()
Esempio n. 38
0
 def __init__(self, application, request, **kwargs):
     BaseHandler.__init__(self, application, request, **kwargs)
     self.query = ""
Esempio n. 39
0
	def initialize(self, *a, **kw):
		BaseHandler.initialize(self, *a, **kw)
		self.error_code = None
Esempio n. 40
0
 def post(self):
   try:
     BaseHandler.initFromRequest(self, self.request)
   except Exception:
     BaseHandler.logException(self)
   BaseHandler.writeResponse(self)
Esempio n. 41
0
 def initialize(self, request, response):
     BaseHandler.initialize(self, request, response)
     self.image_proxy_config = md.get_image_proxy_config()
Esempio n. 42
0
 def initialize(self, request, response):
     BaseHandler.initialize(self, request, response)
     self.values['action'] = self.request.url