I and Kushal DasSayan ChowdhuryGaurav KumarAshish MishraSubhendu GhoshZubin TewariApoorv Ashutosh,Saurabh MandalBiswajit Malakar organized a Hacknight@DGPLUG on 5th feb,2013 from 12am to 4.30am .

Our plan was to create a

Remote C Compiler

The idea is to have a working system which will allow trusted remote systems to submit C programs to a central server and the few build workers will keep monitoring the job queue, they will compile the code and execute it and return the result or any errors back to the users to the remote systems.

It is hosted in here.

Although it is not fully functional yet, I mean the code is not yet designed to sent the output back to the client who sent the compile request. We look forward to getting on and finishing off the tasks as required.

Here ,me and Souradeep and aavrug wrote together this code that would compile the program on the server side. Kushal also helped us. We look forward to getting on and finishing off the tasks as required.

The code is

import tempfile
import os
import subprocess
import sys
from retask.queue import Queue, Job
def file_read(file_name):
    return content,file_name
def main():
    queue = Queue('test')
    while True:
        task = queue.wait()
        name = task.data['filename']
        print "Received", name
        content = task.data['text']
        destdir = writesource(name, content)
        temp_path = os.path.join(destdir, name)
        x = os.path.join(destdir, 'test')
        out, err = system('gcc ' + temp_path + ' -o ' + x)
        if err:
            queue.send(task, err, 120)
            out1, err1 = system(x)
            if err1:
                queue.send(task, err1, 120)
                queue.send(task, out1, 120)

        #print system(x)

def system(cmd):
    Invoke a shell command. Primary replacement for os.system calls.
    ret = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
    stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
    out, err = ret.communicate()
    return out, err
def writesource(name, content):
    destdir = tempfile.mkdtemp(suffix='.' + str(os.getpid()), dir=None)
    return destdir

if __name__== '__main__':

At last,We got success.In the mean time ,we enjoyed very much.We need more this type of hack night.

Special thanks to Kushal.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s