Esempio n. 1
0
	def reparse_all_users(self):
		active_users = self.redis.smembers("active_users")
		if active_users is None:
			return
		for user_id in active_users:
			key = "user_code_{0}".format(user_id)
			val = self.redis.get(key)
			if val is not None:
				c = json.loads(val, use_decimal=True)
			else:
				continue

			code = c.get('raw', None)
			if code is None:
				continue

			try:
				compiled = GridLangParser.parse(
					code,
					constants = CONSTANTS,
					line_limit = self.line_limit,
					const_limit = self.const_limit,
				)
				frozen = compiled.freeze()
				self.freeze_user_code(user_id, frozen)
			except GridLangParseException as e:
				pass
Esempio n. 2
0
	def register_code(self, user_id, raw_url):
		code, err = self.fetch_code(user_id, raw_url)
		if not code:
			if err:
				return False, err
			return False, 'Failed to fetch code from %s' % raw_url

		try:
			compiled = GridLangParser.parse(
				code,
				constants = CONSTANTS,
				line_limit = self.line_limit,
				const_limit = self.const_limit,
			)
			frozen = compiled.freeze()
			self.freeze_user_code(user_id, frozen)
			return True, ""
		except GridLangParseException as e:
			return False, str(e)