#!/usr/bin/python

# continuous_chmod.py
#       --copyright--                   Copyright 2007 (C) Tranzoa, Co. All rights reserved.    Warranty: You're free and on your own here. This code is not necessarily up-to-date or of public quality.
#       --url--                         http://www.tranzoa.net/tzpython/
#       --email--                       pycode is the name to send to. tranzoa.com is the place to send to.
#       --bodstamps--
#       December 20, 2008       bar
#       May 27, 2012            bar     doxygen namespace
#       --eodstamps--
##      \file
#       \namespace              tzpython.continuous_chmod
#
#
#       In a loop, keep chmod'ing a file to the given value.
#
#

import  os
import  sys
import  time


if  __name__ == '__main__' :

    import  TZCommandLineAtFile
    import  TZKeyReady


    del(sys.argv[0])

    TZCommandLineAtFile.expand_at_sign_command_line_files(sys.argv)

    if  len(sys.argv) < 2 :

        print   "Give me the value/string and file name to chmod over and over again every second or so."
        sys.exit(254)

    args        = " ".join(sys.argv)

    print "Hit any key and wait a second to stop this program..."

    while not TZKeyReady.key_ready() :

        fi      = os.popen('chmod ' + args + " 2>&1", "r")      #
        r       = fi.read()
        if  fi.close() != None :
            print "chmod failed: " + r.strip()

        time.sleep(1.1)

    print


#
#
#
# eof
