Changeset 2948 for lliurex-statistics


Ignore:
Timestamp:
Nov 29, 2016, 2:16:32 PM (3 years ago)
Author:
mabarracus
Message:

Add debconf, n4d-vars, dialog confirmation logic

Location:
lliurex-statistics/trunk/fuentes
Files:
9 added
4 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • lliurex-statistics/trunk/fuentes/debian/changelog

    r2775 r2948  
     1lliurex-statistics (0.2) xenial; urgency=medium
     2
     3  * Add debconf, n4d-vars, dialog confirmation logic
     4
     5 -- M.Angel Juan <m.angel.juan@gmail.com>  Thu, 24 Nov 2016 15:46:57 +0100
     6
    17lliurex-statistics (0.1-3) xenial; urgency=medium
    28
  • lliurex-statistics/trunk/fuentes/debian/control

    r2773 r2948  
    88Package: lliurex-statistics
    99Architecture: all
    10 Depends: ${shlibs:Depends}, ${misc:Depends}, auditd, python-daemon
     10Depends: ${shlibs:Depends}, ${misc:Depends}, debconf | debconf-2.0, auditd, python-daemon, n4d, acl
    1111Replaces: lliurex-zero-installer-analytics
    1212Conflicts: lliurex-zero-installer-analytics
  • lliurex-statistics/trunk/fuentes/lliurex-statistics.install/usr/sbin/analytics

    r2773 r2948  
    1616import daemon
    1717import lockfile
     18import xmlrpclib
    1819
    1920######### END CONFIG ###########
     
    7576        LIST.clear()
    7677        # Check if permission flag is granted
    77         #if allow_send(): # DEPRECATED: commented, acceptation not needed
    78         # Send data to master server
    79         send_data()
     78        if allow_send():
     79            # Send data to master server
     80            send_data()
    8081        # Get new temporary filename
    8182        next_filename=get_filename(LOGPATH)
     
    8687#END def change_file():
    8788
    88 #DEPRECATED FUNCTION: acceptation not needed now
    89 #def allow_send():
    90 #    try:
    91 #        if os.path.isfile('/var/tmp/stats/do_stats'):
    92 #            return True
    93 #        else:
    94 #            return False
    95 #    except Exception as e:
    96 #        return False
     89def check_server_acknowledge():
     90        c = xmlrpclib.ServerProxy("https://server:9779/")
     91        return c.get_variable("","VariablesManager","STATS_ENABLED")
     92#END def check_server_acknowledge()
     93
     94def check_local_acknowledge():
     95        answer = None
     96        if os.path.isfile('/etc/lliurex-analytics/status'):
     97            fp = open('/etc/lliurex-analytics/status','r')
     98            answer = fp.readline();
     99            fp.close()
     100        return answer.strip()
     101
     102#END check_local_acknowledge
     103
     104def allow_send():
     105    answer = check_server_acknowledge()
     106    if answer != '1':
     107        answer = check_local_acknowledge()
     108        try:
     109            if answer == "yes":
     110                return True
     111            else:
     112                return False
     113        except Exception as e:
     114            return False
     115    else:
     116        return True
     117#END def allow_send()
     118
    97119#
    98120# Sends data to server and clear all
     
    104126        # clear in-memory list
    105127        LIST.clear()
    106 #        if allow_send():  # DEPRECATED: commented, acceptation not needed
    107         # Send data to master server
    108         send_data()
     128        if allow_send():
     129            # Send data to master server
     130            send_data()
    109131        # Clear database file
    110132        clear_db()
Note: See TracChangeset for help on using the changeset viewer.