File: updateWandbox.py

package info (click to toggle)
wxpython4.0 4.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 221,752 kB
  • sloc: cpp: 962,555; python: 230,573; ansic: 170,731; makefile: 51,756; sh: 9,342; perl: 1,564; javascript: 584; php: 326; xml: 200
file content (47 lines) | stat: -rw-r--r-- 1,357 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python

import json
import os
import urllib2

from scriptCommon import catchPath

def upload(options):
    request = urllib2.Request('http://melpon.org/wandbox/api/compile.json')
    request.add_header('Content-Type', 'application/json')
    response = urllib2.urlopen(request, json.dumps(options))
    return json.loads(response.read())

main_file = '''
#define CATCH_CONFIG_MAIN  // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"

unsigned int Factorial( unsigned int number ) {
    return number <= 1 ? number : Factorial(number-1)*number;
}

TEST_CASE( "Factorials are computed", "[factorial]" ) {
    REQUIRE( Factorial(1) == 1 );
    REQUIRE( Factorial(2) == 2 );
    REQUIRE( Factorial(3) == 6 );
    REQUIRE( Factorial(10) == 3628800 );
}
'''

def uploadFiles():
    response = upload({
        'compiler': 'gcc-head',
        'code': main_file,
        'codes': [{
            'file': 'catch.hpp',
            'code': open(os.path.join(catchPath, 'single_include', 'catch.hpp')).read()
        }],
        'options': 'c++11,cpp-no-pedantic,boost-nothing',
        'compiler-option-raw': '-DCATCH_CONFIG_FAST_COMPILE',
        'save': True
    })

    if 'status' in response and not 'compiler_error' in response:
        return True, response['url']
    else:
        return False, response