<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-

"""Docker container script

This script is used to create a Docker container that hosts the cloud IDE provided
with this repository.

Author:    <NAME>
Copyright: 2016, SAT, FH Technikum Wien
License:   AGPL <http://www.gnu.org/licenses/agpl.txt>

"""

# Imports
import sys, getopt, os, subprocess, shutil, glob, re, wget, tarfile

# Main module
def main(argv):
   
   ant = True
   compiler = True 

   # Check for commandline parameters 
   try:
      opts, args = getopt.getopt(argv,"hn:w:u:k:p:c:d:e:m:s:r:j:o:b",["help","name=","workstationname=","user=","password=","port=","config=","debugport=","websocket=","target=","serial=","projects=","jlinkport=","oocdport=","noob"])
   except getopt.GetoptError:
      print 'python docker_container.py -n <Name> -w <Workstationname> -u <Username> -k <Password> -p <IDE Port> [Optional: -c <Setup Configuration> -d <Debug Port> -e <Websocket Port> -m <Target> -s <Serial> -r <Projects> -j <ON/JLink Port> -o <ON/OOCD Port> -b <Enable NOOB Mode>]'
      sys.exit(2)
   instances = []
   instances.append(opts)

   # check for presence of config file
   for opt, arg in opts:
      if opt in ("-c", "--config"):
        
        try:
            fo = open(arg, "r")
        except IOError:
            print "The file does not exist!"
        instances = []
        cmd = []
        for line in fo:
            
            line = line.replace(" ","")
            line = line.replace("\n","")
            
            param = line.split("=")
            param[0] = "--"+param[0];
            param = tuple(param)
            if param and line and not "cloudinstance:" in line:
             cmd.append(param)
            elif cmd:
             instances.append(cmd)
             cmd = []
        instances.append(cmd)
        fo.close();

   for instance in instances:

       # Initialize build properties
       port = ''
       debugport = ''
       name = ''
       workstationname = ''
       username =''
       password =''
       passwordlen = ''
       sn =''
       wsport = ''
       jlinkport = ''
       oocdport = ''
       startjlink = ''
       startoocd = ''
       projectpath = ''
       noob = False
       target = ''
       compilerfolder = ''
         
       # Loop through parameters and check their validity
       for opt, arg in instance:
          if opt in ("-h", "--help"):
             print 'python docker_container.py -n <Name> -w <Workstationname> -u <Username> -k <Password> -p <IDE Port> [Optional: -c <Setup Configuration> -d <Debug Port> -e <Websocket Port> -m <Target> -s <Serial> -r <Projects> -j <ON/JLink Port> -o <ON/OOCD Port> -b <Enable NOOB Mode>]'
             sys.exit()
          elif opt in ("-p", "--port"):
             port = arg
             if port.isdigit() == False or int(port) > 65535 or int(port) < 1:
              print 'Port (-p) has to be a number in range of 1-65535'
              sys.exit()
          elif opt in ("-d", "--debugport"):
             debugport = arg
             if debugport.isdigit() == False or int(debugport) > 65535 or int(debugport) < 1:
              print 'Port (-d) has to be a number in range of 1-65535'
              sys.exit()
             if debugport == port:
              print 'IDE Port and Debug Port have to be different'
              sys.exit()
          elif opt in ("-e", "--websocket"):
              wsport = arg
              if wsport.isdigit() == False or int(wsport) > 65535 or int(wsport) < 1:
               print 'Port (-e) has to be a number in range of 1-65535'
               sys.exit()
              if wsport == port or wsport == debugport:
               print 'Websocket port has to be different than IDE Port or Debug Port'
               sys.exit()<commit_msg>Fixed minor bug in docker setup<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

"""Docker container script

This script is used to create a Docker container that hosts the cloud IDE provided
with this repository.

Author:    <NAME>
Copyright: 2016, SAT, FH Technikum Wien
License:   AGPL <http://www.gnu.org/licenses/agpl.txt>

"""

# Imports
import sys, getopt, os, subprocess, shutil, glob, re, wget, tarfile

# Main module
def main(argv):
   
   ant = True
   compiler = True
   compilerfolder = ''

   # Check for commandline parameters 
   try:
      opts, args = getopt.getopt(argv,"hn:w:u:k:p:c:d:e:m:s:r:j:o:b",["help","name=","workstationname=","user=","password=","port=","config=","debugport=","websocket=","target=","serial=","projects=","jlinkport=","oocdport=","noob"])
   except getopt.GetoptError:
      print 'python docker_container.py -n <Name> -w <Workstationname> -u <Username> -k <Password> -p <IDE Port> [Optional: -c <Setup Configuration> -d <Debug Port> -e <Websocket Port> -m <Target> -s <Serial> -r <Projects> -j <ON/JLink Port> -o <ON/OOCD Port> -b <Enable NOOB Mode>]'
      sys.exit(2)
   instances = []
   instances.append(opts)

   # check for presence of config file
   for opt, arg in opts:
      if opt in ("-c", "--config"):
        
        try:
            fo = open(arg, "r")
        except IOError:
            print "The file does not exist!"
        instances = []
        cmd = []
        for line in fo:
            
            line = line.replace(" ","")
            line = line.replace("\n","")
            
            param = line.split("=")
            param[0] = "--"+param[0];
            param = tuple(param)
            if param and line and not "cloudinstance:" in line:
             cmd.append(param)
            elif cmd:
             instances.append(cmd)
             cmd = []
        instances.append(cmd)
        fo.close();

   for instance in instances:

       # Initialize build properties
       port = ''
       debugport = ''
       name = ''
       workstationname = ''
       username =''
       password =''
       passwordlen = ''
       sn =''
       wsport = ''
       jlinkport = ''
       oocdport = ''
       startjlink = ''
       startoocd = ''
       projectpath = ''
       noob = False
       target = ''
         
       # Loop through parameters and check their validity
       for opt, arg in instance:
          if opt in ("-h", "--help"):
             print 'python docker_container.py -n <Name> -w <Workstationname> -u <Username> -k <Password> -p <IDE Port> [Optional: -c <Setup Configuration> -d <Debug Port> -e <Websocket Port> -m <Target> -s <Serial> -r <Projects> -j <ON/JLink Port> -o <ON/OOCD Port> -b <Enable NOOB Mode>]'
             sys.exit()
          elif opt in ("-p", "--port"):
             port = arg
             if port.isdigit() == False or int(port) > 65535 or int(port) < 1:
              print 'Port (-p) has to be a number in range of 1-65535'
              sys.exit()
          elif opt in ("-d", "--debugport"):
             debugport = arg
             if debugport.isdigit() == False or int(debugport) > 65535 or int(debugport) < 1:
              print 'Port (-d) has to be a number in range of 1-65535'
              sys.exit()
             if debugport == port:
              print 'IDE Port and Debug Port have to be different'
              sys.exit()
          elif opt in ("-e", "--websocket"):
              wsport = arg
              if wsport.isdigit() == False or int(wsport) > 65535 or int(wsport) < 1:
               print 'Port (-e) has to be a number in range of 1-65535'
               sys.exit()
              if wsport == port or wsport == debugport:
               print 'Websocket port has to be different than IDE Port or Debug Port'
               sys.exit()
{'fraction_non_alphanumeric': 0.13911210644183902, 'fraction_numerical': 0.011592675536819919, 'mean_word_length': 1.8812144212523718, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1504918', 'n_tokens_mistral': 2378, 'n_tokens_neox': 2301, 'n_words': 746}