Skip to content

Commit

Permalink
update r768
Browse files Browse the repository at this point in the history
  • Loading branch information
srz-zumix committed Dec 25, 2014
1 parent 6104ee3 commit 43ce85b
Show file tree
Hide file tree
Showing 6 changed files with 420 additions and 420 deletions.
2 changes: 1 addition & 1 deletion tools/paiza.io/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

.PHONY: sample

TOOLS=pypaiza.py iupaiza.py
TOOLS=paiza.py iupaiza.py

WANDBOX_COMPILER?=gcc-head

Expand Down
6 changes: 3 additions & 3 deletions tools/paiza.io/iupaiza.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import re
import codecs
import argparse
import pypaiza
import paiza

from argparse import ArgumentParser
from pypaiza import PaizaIO
from paiza import PaizaIO

IUTEST_FUSED_SRC = os.path.join(os.path.dirname(__file__), '../../fused-src/iutest.min.hpp')
IUTEST_INCLUDE_REGEX = re.compile(r'^\s*#\s*include\s*".*iutest\.hpp"')
Expand Down Expand Up @@ -48,7 +48,7 @@ def parse_command_line():
parser.add_argument(
'code'
, metavar='CODE'
, help = 'Source code file'
, help = 'source code file'
, nargs='?'
)
if len(sys.argv) <= 1:
Expand Down
182 changes: 91 additions & 91 deletions tools/paiza.io/pypaiza.py → tools/paiza.io/paiza.py
Original file line number Diff line number Diff line change
@@ -1,91 +1,91 @@
#!/usr/bin/env python
#
# pypaiza.py
#

import requests
import json;

#
#
#
class PaizaIO:
"""wandbox api class"""
api_url = 'http://api.paiza.io/'
parameter = { 'source_code':'', 'language':'cpp', 'api_key':'guest' }
session_id = ''

def create(self):
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
payload = json.dumps(self.parameter)
r = requests.post(self.api_url + 'runners/create/', data=payload, headers=headers)
r.raise_for_status()
result = r.json()
if 'error' in result:
if not 'longpoll timeout' in result['error']:
print result['error']
print result
raise

if 'id' in result:
self.session_id = result['id']
else:
print result
raise
return result

def get_status(self):
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
parameter = { 'id': self.session_id, 'api_key':self.parameter['api_key'] }
payload = json.dumps(parameter)
r = requests.get(self.api_url + 'runners/get_status/', data=payload, headers=headers)
r.raise_for_status()
return r.json()

def get_details(self):
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
parameter = { 'id': self.session_id, 'api_key':self.parameter['api_key'] }
payload = json.dumps(parameter)
r = requests.get(self.api_url + 'runners/get_details/', data=payload, headers=headers)
r.raise_for_status()
return r.json()

def is_completed(self, r):
if 'status' in r:
return r['status'] == 'completed'
return False

def wait_complete(self):
r = self.get_status()
while not self.is_completed(r):
r = self.get_status()

def run(self):
r = self.create()
while not self.is_completed(r):
r = self.get_status()
return self.get_details()

def language(language, str):
self.parameter.update({'language':str})
def source_code(source_code, str):
self.parameter.update({'source_code':str})
def code(self, str):
self.parameter.update({'source_code':str})
def input(self, str):
self.parameter.update({'input':str})
def stdin(self, str):
self.parameter.update({'input':str})
def longpoll(self, b):
self.parameter.update({'longpoll':b})
def longpoll_timeout(self, t):
self.parameter.update({'longpoll_timeout':t})

def dump(self):
print self.parameter

if __name__ == '__main__':
paiza = PaizaIO()
paiza.code('#include <iostream>\nint main() { int x = 0; std::cout << "hoge" << std::endl; }')
print paiza.run()
#!/usr/bin/env python
#
# pypaiza.py
#

import requests
import json

#
#
#
class PaizaIO:
"""wandbox api class"""
api_url = 'http://api.paiza.io/'
parameter = { 'source_code':'', 'language':'cpp', 'api_key':'guest' }
session_id = ''

def create(self):
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
payload = json.dumps(self.parameter)
r = requests.post(self.api_url + 'runners/create/', data=payload, headers=headers)
r.raise_for_status()
result = r.json()
if 'error' in result:
if not 'longpoll timeout' in result['error']:
print result['error']
print result
raise

if 'id' in result:
self.session_id = result['id']
else:
print result
raise
return result

def get_status(self):
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
parameter = { 'id': self.session_id, 'api_key':self.parameter['api_key'] }
payload = json.dumps(parameter)
r = requests.get(self.api_url + 'runners/get_status/', data=payload, headers=headers)
r.raise_for_status()
return r.json()

def get_details(self):
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
parameter = { 'id': self.session_id, 'api_key':self.parameter['api_key'] }
payload = json.dumps(parameter)
r = requests.get(self.api_url + 'runners/get_details/', data=payload, headers=headers)
r.raise_for_status()
return r.json()

def is_completed(self, r):
if 'status' in r:
return r['status'] == 'completed'
return False

def wait_complete(self):
r = self.get_status()
while not self.is_completed(r):
r = self.get_status()

def run(self):
r = self.create()
while not self.is_completed(r):
r = self.get_status()
return self.get_details()

def language(language, str):
self.parameter.update({'language':str})
def source_code(source_code, str):
self.parameter.update({'source_code':str})
def code(self, str):
self.parameter.update({'source_code':str})
def input(self, str):
self.parameter.update({'input':str})
def stdin(self, str):
self.parameter.update({'input':str})
def longpoll(self, b):
self.parameter.update({'longpoll':b})
def longpoll_timeout(self, t):
self.parameter.update({'longpoll_timeout':t})

def dump(self):
print self.parameter

if __name__ == '__main__':
paiza = PaizaIO()
paiza.code('#include <iostream>\nint main() { int x = 0; std::cout << "hoge" << std::endl; }')
print paiza.run()

2 changes: 1 addition & 1 deletion tools/wandbox/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

.PHONY: sample

TOOLS=pywandbox.py iuwandbox.py
TOOLS=wandbox.py iuwandbox.py

WANDBOX_COMPILER?=gcc-head

Expand Down
Loading

0 comments on commit 43ce85b

Please sign in to comment.