<commit_before>#! /usr/bin/env python
# -*- coding: ascii -*-

# we do need a few libraries (pretty standard ones, except for serial, which might have to be installed)
import signal, os, sys, serial,time, uuid, glob, re
import platform
from libawsman import *
from datetime import datetime
from datetime import timedelta

try:
  import config
except:
  "Print starting configuration"

# Purpose of this script:
# 1) Manage the Arduino based weather station running my 'weather_logger' software. 
# 2) Store data on a http server running my microsds service (php/PostgreSQL/PostGIS).
# 3) Manage your stations in the microsds service

####################################################################
# License #########################################################
####################################################################

# The MIT License (MIT)
# 
# Copyright (c) 2014 <NAME>
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

print ""
print "*********************************************************"
print "* Client for the Arduino weather station and webservice *"
print "* (c) <NAME> 2014                               *"
print "* License: MIT                                          *"
print "*********************************************************"
print ""

####################################################################
# A few Function definitions, most are in libawsman.py #############
####################################################################

# Online, test microsds service ####################################
def testGenerateConfig():
  if not os.path.exists("config.py"):
    MSDSERVER = raw_input("Micro SDS Server: ")
    MSDSERVERPATH = raw_input("Service path:     ")
    SERIALPORT = raw_input("Serial port:      ")
    f = open('config.py','w')
    f.write('MSDSERVER="'+MSDSERVER+"\"\n")
    f.write('MSDSERVERPATH="/'+MSDSERVERPATH.strip("/")+"\"\n")
    f.write('SERIALPORT="'+SERIALPORT+"\"\n")
    f.close()
    print "Configuration written to config.py."
    sys.exit()

# The various online modi, note that streaming and data input are missing here:
# they automatically cache stuff and can be used offline, test-microsds also
# missing: test would otherwise be executed twice
onlinemodi = ['station-insert', 'station-delete'
    , 'station-disable', 'station-enable'
    , 'data-upload', 'cache-purge']

def testMicroSds(mode):
  if (mode in onlinemodi):
    tr = testMicroSdsConfig()
    if tr <> 0:
      sys.exit()

# COM port #######################################################
def getSerialPort(portname):
  ttyport = ""
  if portname == "port:auto" or portname == "port:config":
    if platform.system().startswith('Win') or portname == "port:config":
      ttyport = SERIALPORT
    elif platform.system() == "Darwin":
      ttys = glob.glob("/dev/tty.usbmodem*")
      ttyport = ttys[0]
    elif platform.system() == "Linux":
      ttys = glob.glob("/dev/ttyUSB*")
      ttyport = ttys[0]
    else:
      ttyport = portname
  else:
    ttyport = portname
  print "Using serial port: " + ttyport
  return ttyport

# Help ###########################################################
def printHelp(section):
  f = open('usage.txt','r')
  insection = False
  if section == "":
    for line in f.readlines():
      print line.rstrip()<commit_msg>Changed auto-search port for Linux from USB to ACM.<commit_after>#! /usr/bin/env python
# -*- coding: ascii -*-

# we do need a few libraries (pretty standard ones, except for serial, which might have to be installed)
import signal, os, sys, serial,time, uuid, glob, re
import platform
from libawsman import *
from datetime import datetime
from datetime import timedelta

try:
  import config
except:
  "Print starting configuration"

# Purpose of this script:
# 1) Manage the Arduino based weather station running my 'weather_logger' software. 
# 2) Store data on a http server running my microsds service (php/PostgreSQL/PostGIS).
# 3) Manage your stations in the microsds service

####################################################################
# License #########################################################
####################################################################

# The MIT License (MIT)
# 
# Copyright (c) 2014 <NAME>
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

print ""
print "*********************************************************"
print "* Client for the Arduino weather station and webservice *"
print "* (c) <NAME> 2014                               *"
print "* License: MIT                                          *"
print "*********************************************************"
print ""

####################################################################
# A few Function definitions, most are in libawsman.py #############
####################################################################

# Online, test microsds service ####################################
def testGenerateConfig():
  if not os.path.exists("config.py"):
    MSDSERVER = raw_input("Micro SDS Server: ")
    MSDSERVERPATH = raw_input("Service path:     ")
    SERIALPORT = raw_input("Serial port:      ")
    f = open('config.py','w')
    f.write('MSDSERVER="'+MSDSERVER+"\"\n")
    f.write('MSDSERVERPATH="/'+MSDSERVERPATH.strip("/")+"\"\n")
    f.write('SERIALPORT="'+SERIALPORT+"\"\n")
    f.close()
    print "Configuration written to config.py."
    sys.exit()

# The various online modi, note that streaming and data input are missing here:
# they automatically cache stuff and can be used offline, test-microsds also
# missing: test would otherwise be executed twice
onlinemodi = ['station-insert', 'station-delete'
    , 'station-disable', 'station-enable'
    , 'data-upload', 'cache-purge']

def testMicroSds(mode):
  if (mode in onlinemodi):
    tr = testMicroSdsConfig()
    if tr <> 0:
      sys.exit()

# COM port #######################################################
def getSerialPort(portname):
  ttyport = ""
  if portname == "port:auto" or portname == "port:config":
    if platform.system().startswith('Win') or portname == "port:config":
      ttyport = SERIALPORT
    elif platform.system() == "Darwin":
      ttys = glob.glob("/dev/tty.usbmodem*")
      ttyport = ttys[0]
    elif platform.system() == "Linux":
      ttys = glob.glob("/dev/ttyACM*")
      ttyport = ttys[0]
    else:
      ttyport = portname
  else:
    ttyport = portname
  print "Using serial port: " + ttyport
  return ttyport

# Help ###########################################################
def printHelp(section):
  f = open('usage.txt','r')
  insection = False
  if section == "":
    for line in f.readlines():
      print line.rstrip()
{'fraction_non_alphanumeric': 0.23006205470006896, 'fraction_numerical': 0.003217651114686279, 'mean_word_length': 4.26497277676951, 'pattern_counts': {'":': 10, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1304938', 'n_tokens_mistral': 2343, 'n_tokens_neox': 2226, 'n_words': 859}