Ejemplo n.º 1
0
def run_code(code, language):
    ideone_api = Ideone(
        constants.IDEONE_USERNAME,
        constants.IDEONE_PASSWORD,
        api_url='http://ronreiter.compilers.sphere-engine.com/api/1/service.wsdl')

    code = ideone_api.create_submission(code, language_name=language, std_input="")["link"]
    result = None

    while True:
        time.sleep(1)
        result = ideone_api.submission_details(code)
        if result["status"] in [1,3]:
            continue

        break

    data = { "code" : code }
    if result["stderr"] or result["cmpinfo"]:
        data["output"] = "exception"
        if result["cmpinfo"]:
            data["text"] = result["cmpinfo"]
        elif result["stderr"]:
            data["text"] = result["stderr"]
    else:
        data["output"] = "text"
        data["text"] = result["output"]

    return data
Ejemplo n.º 2
0
def run_code(code, language_id):
    ideone_api = Ideone(
        constants.IDEONE_USERNAME,
        constants.IDEONE_PASSWORD,
        api_url='http://ronreiter.compilers.sphere-engine.com/api/1/service.wsdl')

    code = ideone_api.create_submission(code, language_id=language_id, std_input="")["link"]
    result = None

    while True:
        time.sleep(1)
        result = ideone_api.submission_details(code)
        if result["status"] in [1,3]:
            continue

        break

    data = { "code" : code }
    if result["stderr"] or result["cmpinfo"]:
        data["output"] = "exception"
        if result["cmpinfo"]:
            data["text"] = result["cmpinfo"]
        elif result["stderr"]:
            data["text"] = result["stderr"]
    else:
        data["output"] = "text"
        data["text"] = result["output"]

    return data
Ejemplo n.º 3
0
def code_solution_compile(request):
    source_code = request.POST.get('source_code', None)
    language = request.POST.get('language', None)
    
    if not (source_code and language):
        return {
            'status_code': 500,
            'error': u'Wybierz język programowania oraz podaj kod źródłowy.'
        }
    
    last_submit = cache.get(IDEONET_CACHE_KEY % request.user.id)
    if last_submit:
        last_submit_diff = datetime.now() - last_submit
        
        if last_submit_diff.seconds <= IDEONET_CACHE_TIME:
            return {
                'status_code': 500,
                'error': u'Ponowna kompilacja będzie możliwa za {}s.'\
                    .format(IDEONET_CACHE_TIME - last_submit_diff.seconds)
            }
        
    ide = Ideone(settings.IDEONE_USER, settings.IDEONE_PASSWORD)
    try:
        submission = ide.create_submission(source_code, language_name=language, private=True)
    except IdeoneError:
        code_language = CodeLanguage.objects.get(code=language)
        
        submission = ide.create_submission(source_code, language_name=code_language.name, 
                                           private=True)
        
    cache.set(IDEONET_CACHE_KEY % request.user.id, datetime.now(), IDEONET_CACHE_TIME)
    
    if submission.get('error', 'OK') != 'OK':
        return {
            'status_code': 500,
            'error': submission.get('error', u'Wystąpił błąd podczas kompilowania rozwiązania'),
        }
        
    link = submission.get('link', '')
    
    return {
        'status_code': 200,
        'link': link,
    }
Ejemplo n.º 4
0
         D
         AWK gawk-3.1.6
         AWK mawk-1.3.3
         COBOL 85
         Forth
         Prolog
         bc
         Clojure
         JavaScript
         Go
         Unlambda
         Python 3
         R
         COBOL
         Oz
         Groovy
         Nimrod
         Factor
         F#
         Falcon
    '''
    sys.exit(1)

lang  = sys.argv[1]
print "Paste: and CTRL+D to End the paste..."
paste = sys.stdin.read()
i = Ideone('username', 'APIKey')
res = i.create_submission(paste, lang)
link = res['link']
print "http://www.ideone.com/" + link
import os
from ideone import Ideone

i = Ideone(os.getenv("IDEUSER"), os.getenv("IDEPASS"))
print i.create_submission("print(42)", language_name="python", run=False)
import os
from ideone import Ideone
i = Ideone(os.getenv('IDEUSER'), os.getenv('IDEPASS'))
print(i.create_submission('print(42)', language_name='python', run=False))
Ejemplo n.º 7
0
         D
         AWK gawk-3.1.6
         AWK mawk-1.3.3
         COBOL 85
         Forth
         Prolog
         bc
         Clojure
         JavaScript
         Go
         Unlambda
         Python 3
         R
         COBOL
         Oz
         Groovy
         Nimrod
         Factor
         F#
         Falcon
    '''
    sys.exit(1)

lang = sys.argv[1]
print "Paste: and CTRL+D to End the paste..."
paste = sys.stdin.read()
i = Ideone('username', 'APIKey')
res = i.create_submission(paste, lang)
link = res['link']
print "http://www.ideone.com/" + link