Beispiel #1
0
def credentials_from_netrc(remoteHostName=None):
    import netrc
    if remoteHostName is None:
        remoteHostName = "nrt.cmems-du.eu"
    # get user home path
    usrhome = os.getenv("HOME")
    netrc = netrc.netrc()
    user = netrc.authenticators(remoteHostName)[0]
    pw = netrc.authenticators(remoteHostName)[2]
    return user, pw
def get_user_password():
    import netrc
    netrc = netrc.netrc()
    info = netrc.authenticators(HOST)
    if info is None:
        sys.exit('~/.netrc should include: machine #{HOST} login [...] '
                 'password [...]')
    return info[0], info[2]
Beispiel #3
0
    def _check_credential(self):
        home_dir = os.environ.get('HOME')
        fpath = os.path.join(home_dir, '.netrc')

        if os.path.exists(fpath):
            import netrc
            netrc = netrc.netrc()
            remoteHostName = 'ooinet.oceanobservatories.org'
            info = netrc.authenticators(remoteHostName)
            return info[0], info[2]
        else:
            raise EnvironmentError('Please authenticate by using visualocean.utils.set_credentials_file!')
Beispiel #4
0
def query_netrc(server):
    netrc = netrc.netrc()
    authTokens = netrc.authenticators(server)
    return authTokens[0], authTokens[2]
Beispiel #5
0
# Ainsi que le fichier Virtualhost du serveur Apache
tar = tarfile.open(dir_backup + nom_backup_file, 'w:gz')
tar.add(dir_wordpress)
tar.add(dir_site_apache + virtual_host)
tar.close()

# Récupération de la liste des fichiers  de sauvegarde pour serveur local et FTP
backup_files = supp_old_backup(backup_type[0], base_name, dir_backup)
backup_bases = supp_old_backup(backup_type[1], base_name, dir_backup)

# ##### ACTIONS SUR LE SERVEUR FTP ###### #

# Récupération des informations de connexion du serveur ftp contenu dans le fichier protégé .netrc
try:
    netrc = netrc.netrc()
    auth_ftp = netrc.authenticators(ftp_host)
except FileNotFoundError:
    print(
        'Warning : Fichier d\'identification FTP non présent. L\'accès au serveur impossible'
    )
    sys.exit(2)

# Partie de connexion au serveur FTP et transfert des fichiers de sauvegarde
with ftplib.FTP(host=ftp_host, user=auth_ftp[0], passwd=auth_ftp[2]) as ftp:
    try:
        print(ftp.getwelcome())
        ftp.cwd(dir_ftp)
        ftp.storbinary('STOR ' + nom_backup_file,
                       open(dir_backup + nom_backup_file, 'rb'))
        ftp.storbinary('STOR ' + nom_backup_base,
                       open(dir_backup + nom_backup_base, 'rb'))
Beispiel #6
0
mapbox_access_token = "pk.eyJ1Ijoia2dsYXZpbiIsImEiOiJjamd6ZjgzZDkwZWJlMnFyNG1wN3ZlMXVwIn0.qygVV7-zi8IMX8wyxawEpA"
mapbox_access_token = os.environ.get('MAPBOX_ACCESS_TOKEN', 'mapbox-token')

realm = 'https://catfish3.riverbed.cc'
hosts = ['kglavin-us', 'kglavin-eur', 'kglavin-asia' ]
users = []
pw=[]




if __name__ == '__main__':

    gpsdict = gps.gendict()
    netrc = netrc.netrc()


    for host in hosts:
        authTokens = netrc.authenticators(host)
        user = authTokens[0]
        users.append(user)
        pw = authTokens[2]
        get_sites(sitedf, realm, user, pw)
        get_nodes(nodedf, sitedf, realm, user, pw)
        #get_eventlogs(eventdf,realm,user,pw) 
        get_uplinks(uplinkdf,sitedf, realm, user, pw)
        
    gen_sites_snmp(sites_snmpdf,uplinkdf)
    print(sites_snmpdf)

# Sample script to get netCDF plotting working for CAHW-2018
# cpsarason

import netrc
netrc = netrc.netrc()
remoteHostName = "ooinet.oceanobservatories.org"
info = netrc.authenticators(remoteHostName)
username = info[0]
token = info[2]

import requests
import time

subsite = 'RS03ASHS'
node = 'MJ03B'
sensor = '07-TMPSFA301'
method = 'streamed'
stream = 'tmpsf_sample'
beginDT = '2014-09-27T01:01:01.000Z' #begin of first deployement
endDT = None

base_url = 'https://ooinet.oceanobservatories.org/api/m2m/12576/sensor/inv/'

data_request_url ='/'.join((base_url,subsite,node,sensor,method,stream))
params = {
         'beginDT':beginDT,
         'endDT':endDT,   
         }

r = requests.get(data_request_url, auth=(username, token))
data = r.json()
Beispiel #8
0
             'Denver':'44.1.0.13',
             'Albuquerque':'44.1.0.14',
             'ElPaso':'44.1.0.15',
             'Houston':'44.1.0.16',
             'NewOrleans':'44.1.0.17',
             'SanAntonio':'44.1.0.18',
             'Amsterdam':'44.1.0.21',
             'Frankfurt':'44.1.0.23',
             'Paris':'44.1.0.22',
             'Bangkok':'44.1.0.31',
             'HochiMihn':'44.1.0.33',
             'KualaLumpar':'44.1.0.32',

            }

    authTokens = netrc.authenticators('scm-snmp')
    community = authTokens[2]
    client = InfluxDBClient(host='influxdb', port=8086)
    client.switch_database('scmdata')
    pool = mp.Pool(processes=4)

    measurement_count = 0
    good_measurement_writes = 0
    bad_measurement_writes = 0
    poll_time_measures = []

    sites_refresh_count = 20
    old_sites = {}

    logging.debug('starting main loop')
    while True:
Beispiel #9
0
import netrc

# Reads well depth information from NodeMCU sitting at the top of the well

# 2019-03-20 - Initial implementation
# 2019-04-13 - Added Email Alert
# 2020-01-26 - After running out of water yesterday I adjusted warning thresholds.
# 			 -

#########################################################################
############ Main Program ###############################################
########################################################################

netrc = netrc.netrc()

authTokens_gmail = netrc.authenticators("smtp.gmail.com")
authTokens_sql = netrc.authenticators("localhost_sql_server")

smtp_server = "smtp.gmail.com"
port = 587  # For starttls
sender_email = authTokens_gmail[0]
receiver_email = "*****@*****.**"
password = authTokens_gmail[2]

warning_1 = 160  # 2020-01-26 - Changed from 150 to 160
warning_2 = 110  # 2020-01-26 - Changed from 100 to 110
warning_3 = 75  # 2020-01-26 - Changed from
cutoff_point = 60  # NOT USED YET

url = "http://192.168.1.115/"
#with urllib.request.urlopen(url) as url: