Exemple #1
0
	def get(self, resource):
		query = Replay.all()
                query.filter('replayid =', resource)

                results = query.fetch(1)

                if results:
			num_results = len(results)
                        result = results[0]
                        blob_info = blobstore.BlobInfo.get(result.blobinfo)
			original_filename = blob_info.filename
			filesize = blob_info.size
			dl_count = get_count(resource)
		else:
			num_results = 0
			original_filename = ""
			filesize = ""
			dl_count = 0

		upload_url = blobstore.create_upload_url('/upload')
		path = os.path.join(os.path.dirname(__file__), 'info.html')
		self.response.headers['Cache-Control'] = 'no-cache'
		self.response.headers['Pragma'] = 'no-cache'

		template_values = {
                        'upload_url': upload_url,
			'counter': counter_as_string('principal'),
			'resource': resource,
			'num_results': num_results,
			'original_filename': original_filename,
			'filesize': filesize,
			'dl_count': dl_count,
		}
		self.response.out.write(template.render(path, template_values))
Exemple #2
0
    def get(self, resource):
        query = Replay.all()
        query.filter('replayid =', resource)

        results = query.fetch(1)

        if results:
            num_results = len(results)
            result = results[0]
            blob_info = blobstore.BlobInfo.get(result.blobinfo)
            original_filename = blob_info.filename
            filesize = blob_info.size
            dl_count = get_count(resource)
        else:
            num_results = 0
            original_filename = ""
            filesize = ""
            dl_count = 0

        upload_url = blobstore.create_upload_url('/upload')
        path = os.path.join(os.path.dirname(__file__), 'info.html')
        self.response.headers['Cache-Control'] = 'no-cache'
        self.response.headers['Pragma'] = 'no-cache'

        template_values = {
            'upload_url': upload_url,
            'counter': counter_as_string('principal'),
            'resource': resource,
            'num_results': num_results,
            'original_filename': original_filename,
            'filesize': filesize,
            'dl_count': dl_count,
        }
        self.response.out.write(template.render(path, template_values))
Exemple #3
0
    def get(self, resource, extension=".SC2Replay"):
        if resource[-10:] in (".SC2Replay", ".sc2replay"):
            resource = resource[0:-10]
        query = Replay.all()
        query.filter('replayid =', resource)

        results = query.fetch(1)

        if results:
            result = results[0]
            blob_info = blobstore.BlobInfo.get(result.blobinfo)
            if blob_info:
                upload_url = blobstore.create_upload_url('/upload')
                path = os.path.join(os.path.dirname(__file__), 'download.html')
                self.response.headers['Cache-Control'] = 'no-cache'
                self.response.headers['Pragma'] = 'no-cache'

                baseurl = urlparse(self.request.url).netloc

                if "sc2share.com" in baseurl:
                    baseurl = "sc2share.com"

                template_values = {
                    'download_filename':
                    blob_info.filename.encode("utf-8"),
                    'download_url':
                    'd/%s/%s' %
                    (resource, quote(blob_info.filename.encode("utf-8"))),
                    'baseurl':
                    baseurl,
                }
                self.response.out.write(template.render(path, template_values))
                return
            else:
                reason = 'nosuchfile'
        else:
            reason = 'nosuchfile'

        upload_url = blobstore.create_upload_url('/upload')
        path = os.path.join(os.path.dirname(__file__), 'nofetch.html')
        self.response.headers['Cache-Control'] = 'no-cache'
        self.response.headers['Pragma'] = 'no-cache'

        failure_reasons = {}
        failure_reasons['pt'] = {
            'nosuchfile':
            'O arquivo pedido não existe. Pode ser que ele nunca tenha existido, pode ser que ele tenha sido apagado, e pode ser que algo catastrófico tenha acontecido. Difícil dizer o que foi.'
        }
        failure_reasons['en'] = {
            'nosuchfile':
            'The requested file does not exist. Maybe it never existed, maybe it has been deleted, maybe something catastrophic happened. In any case, we apologize.'
        }

        template_values = {
            'upload_url': upload_url,
            'errormsg': failure_reasons['en'][reason]
        }
        self.response.out.write(template.render(path, template_values))
Exemple #4
0
	def get(self, resource, extension):
		query = Replay.all()
		query.filter('replayid =', resource)

		results = query.fetch(1)

		if results:
			result = results[0]
			blob_info = blobstore.BlobInfo.get(result.blobinfo)
			increment(resource)
			self.send_blob(blob_info)
			return
Exemple #5
0
    def get(self, resource, extension):
        query = Replay.all()
        query.filter('replayid =', resource)

        results = query.fetch(1)

        if results:
            result = results[0]
            blob_info = blobstore.BlobInfo.get(result.blobinfo)
            increment(resource)
            self.send_blob(blob_info)
            return
Exemple #6
0
	def get(self, resource, extension=".SC2Replay"):
		if resource[-10:] in (".SC2Replay", ".sc2replay"):
			resource = resource[0:-10]
		query = Replay.all()
		query.filter('replayid =', resource)

		results = query.fetch(1)

		if results:
			result = results[0]
			blob_info = blobstore.BlobInfo.get(result.blobinfo)
			if blob_info:
				upload_url = blobstore.create_upload_url('/upload')
				path = os.path.join(os.path.dirname(__file__), 'download.html')
				self.response.headers['Cache-Control'] = 'no-cache'
				self.response.headers['Pragma'] = 'no-cache'

				baseurl = urlparse(self.request.url).netloc;

				if "sc2share.com" in baseurl:
					baseurl = "sc2share.com"

				template_values = {
					'download_filename': blob_info.filename.encode("utf-8"),
					'download_url': 'd/%s/%s' % (resource, quote(blob_info.filename.encode("utf-8"))),
					'baseurl': baseurl,
				}
				self.response.out.write(template.render(path, template_values))
				return
			else:
				reason = 'nosuchfile'
		else:
			reason = 'nosuchfile'

		upload_url = blobstore.create_upload_url('/upload')
		path = os.path.join(os.path.dirname(__file__), 'nofetch.html')
		self.response.headers['Cache-Control'] = 'no-cache'
		self.response.headers['Pragma'] = 'no-cache'

		failure_reasons = {}
		failure_reasons['pt'] = {
			'nosuchfile': 'O arquivo pedido não existe. Pode ser que ele nunca tenha existido, pode ser que ele tenha sido apagado, e pode ser que algo catastrófico tenha acontecido. Difícil dizer o que foi.'
		}
		failure_reasons['en'] = {
			'nosuchfile': 'The requested file does not exist. Maybe it never existed, maybe it has been deleted, maybe something catastrophic happened. In any case, we apologize.'
		}
		
		template_values = {
			'upload_url': upload_url,
			'errormsg': failure_reasons['en'][reason]
		}
		self.response.out.write(template.render(path, template_values))