- name = raw_video[:raw_video.rindex('.')]
- transcode_config = {
- 'container': container,
- 'a_codec': a_codec,
- 'a_bitrate': a_bitrate,
- 'v_codec': v_codec,
- 'v_bitrate': v_bitrate,
- 'v_resolution': v_resolution
- }
- thumbs = 'random'
-
- job = {
- 'raw_video': raw_video,
- 'name': name,
- 'transcode_configs': [transcode_config],
- 'thumbs': thumbs
- }
-
- queue.put(job)
+ def __del__(self):
+ self.shared.queue.join()
+
+ def GET(self, request):
+ #web.header('Cache-Control', 'no-cache')
+
+ if request == 'get_load':
+ resp = {"load": self.shared.load}
+ print 'load in GET is', self.shared.load
+ web.header('Content-Type', 'application/json')
+ return json.dumps(resp)
+ else:
+ web.badrequest()
+ return ""
+
+
+ def POST(self, request):
+ if request == 'ingest_content':
+ # Read JSON parameters.
+ json_data = web.data()
+ data = json.loads(json_data)
+
+ # Add job weight to CIS load.
+ self.shared.load += data["weight"]
+ print 'load in POST is', self.shared.load
+
+ # Submit job.
+ self.shared.queue.put(data)
+
+ return 'Job submitted.'
+ else:
+ web.badrequest()
+ return ""
+
+
+if __name__ == '__main__':
+ # The BitTorrent object implements a NextShare (Tribler) BitTorrent
+ # client for seeding, downloading etc.
+ global bit_torrent
+ bit_torrent = bt.BitTorrent()