示例#1
0
def process_it(script, dependencies, tmpdirname):
   """
   <Purpose>
     Copy into the directory and process all the files needed for the script.
     Remove unneeded files after processing.

   <Args>
     script - the main module to build
     dependencies - the files the main script includes or imports
     tmpdirname - the temporary directory
   <Side Effects>
     Leaves the minimal set of files neccessary to run the script in the tmp dir
   """

   target_dir = tmpdirname
   current_dir = os.getcwd()

   # copy them all in
   for filepath in dependencies:
     preparetest.copy_to_target(filepath, target_dir)

   # add some utils
   preparetest.copy_to_target("seattlelib/repypp.py", target_dir)

   #set working directory to the test folder
   os.chdir(target_dir)

   #call the process_mix function to process all mix files in the target directory
   preparetest.process_mix("repypp.py")

   # rm build files
   files_to_remove = glob.glob("*.mix") + glob.glob("*.repy") + \
       glob.glob("*.r2py")
   for fn in files_to_remove: 
     os.remove(fn)
   os.remove("repypp.py") # get rid of the repypp.py file

   #go back to root project directory
   os.chdir(current_dir) 
def main():
  """
  <Purpose>
    Deploys the opendhtputget.py along with all the files needed into a
    single directory. The directory must already exist.

  <Exceptions>
    If OS is not Linux, then setting up crontab will not work.

  <Side Effect>
    If the target directory that the user provides is not empty, then this script will delete all the files
    that already exist in that directory.
	
  <Usage>
    make a folder that lies in the same directory as the trunk director and copy this file and setup_crontab.py in that file. Go to the trunk folder in the svn checkout directory and run the command: python preparetest.py <../folder_name>. Then copy over preparetest.py in that folder as well.  
    PYTHONPATH=$PYTHONPATH:/home/<user_name>/trunk && deploy_opendhtputget.py <target_folder>

  """

  checkArgs()

  #setup some variables for cron setup
  cron_setup = False
  log_dir = ""

  # -c means we have to setup the crontab with a new cron job
  if sys.argv[1] == '-c':
    cron_setup = True
    sys.argv = sys.argv[1:]
    checkArgs(cron_setup)
    log_dir = sys.argv[2]
    
    if not( os.path.isdir(log_dir) ):
      help_exit("given log_foldername is not a directory")

  #set up all the variables about directory information
  current_dir = os.getcwd()
  
  #ensures that the backslashes and forward slashes are proper for the OS
  target_dir = os.path.normpath(sys.argv[1])

  #make sure svn is up to date and start up preparetest
  os.chdir(os.path.normpath(current_dir + "/../trunk"))
  os.system("svn up")
  os.chdir(current_dir)
  preparetest.main()

  if not( os.path.isdir(target_dir) ):
    help_exit("given foldername is not a directory")

  #change to target directory and clean up the target directory folder
  os.chdir(target_dir)

  files_to_remove = glob.glob("*")

  for f in files_to_remove:
    if os.path.isdir(f):
      shutil.rmtree(f)
    else:
      os.remove(f)

  os.chdir(current_dir)

  #copy necessary files over
  #an alternative to the copy_to_target code, is to manually copy these two files over
  preparetest.copy_to_target("../trunk/repy/*", target_dir)
  preparetest.copy_to_target("../trunk/nodemanager/*", target_dir)
  preparetest.copy_to_target("../trunk/portability/*", target_dir)
  preparetest.copy_to_target("../trunk/seattlelib/*", target_dir)
  preparetest.copy_to_target("../trunk/seash/*", target_dir)
  preparetest.copy_to_target("../trunk/softwareupdater/*", target_dir)
  preparetest.copy_to_target("../trunk/autograder/nm_remote_api.mix", target_dir)
  preparetest.copy_to_target("../trunk/keydaemon/*", target_dir)
  
  #the next few lines is necessary unless the file is manually copied over
  preparetest.copy_to_target("../trunk/integrationtests/opendhtputget/*", target_dir)
  preparetest.copy_to_target("../trunk/integrationtests/common/*", target_dir)
  
  #change directory to the target directory and preprocess the *.mix files
  os.chdir(target_dir)
  preparetest.process_mix(current_dir+"/repypp.py")
  

  #check to see if cron setup was requested, if yes run cron_setup
  if cron_setup:

    #create the absolute path for the log file and the file needed for the 
    #cron job
    cron_tab_dir=os.path.normpath(current_dir + "/" + target_dir)
    cron_log_dir=os.path.normpath(current_dir + "/" + log_dir)
    
    cron_line="30 * * * * export GMAIL_USER='******' && export GMAIL_PWD='repyrepy' && /usr/bin/python " + cron_tab_dir + "/opendhtputget.py >> " + cron_log_dir + "/cron_log.opendhtputget 2>&1" + os.linesep

    #setup the cron job
    setup_crontab.add_crontab(cron_line, "opendhtputget")
示例#3
0
def main():
  """
  <Purpose>
    Deploys the monitor_processes.py along with all the files needed into a
    single directory. The directory must already exist.

  <Exceptions>
    If OS is not Linux, then setting up crontab will not work.
	
  <Side Effect>
    If the target directory that the user provides is not empty, then this script will delete all the files
    that already exist in that directory.	

  <Usage>
    make a folder that lies in the same directory as the trunk director and copy this file and setup_crontab.py in that file. Go to the trunk folder in the svn checkout directory and run the command: python preparetest.py <../folder_name>. Then copy over preparetest.py in that folder as well.  
    PYTHONPATH=$PYTHONPATH:/home/<user_name>/trunk && deploy_monitor_processes.py <target_folder>

  """

  checkArgs()

  #setup some variables for cron setup
  cron_setup = False
  log_dir = ""

  #variables that check which machine is being setup  
  setup_seattle=False
  setup_seattlegeni=False
  
  # -cseattle means we have to setup the crontab with a new cron job on the machine seattle
  if sys.argv[1] == '-cseattle':
    cron_setup = True
    sys.argv = sys.argv[1:]
    checkArgs(cron_setup)
    log_dir = sys.argv[2]
    setup_seattle=True
    
    if not( os.path.isdir(log_dir) ):
      help_exit("given log_foldername is not a directory")

  # -cseattlegeni means we have to setup the crontab with a new cron job on the machine seattlegeni	  
  elif sys.argv[1] == '-cseattlegeni':
    cron_setup = True
    sys.argv = sys.argv[1:]
    checkArgs(cron_setup)
    log_dir = sys.argv[2]
    setup_seattlegeni=True    
	
    if not( os.path.isdir(log_dir) ):
      help_exit("given log_foldername is not a directory")

  #set up all the variables about directory information
  current_dir = os.getcwd()
  
  #ensures that the backslashes and forward slashes are proper for the OS
  target_dir = os.path.normpath(sys.argv[1])

  #make sure svn is up to date and start up preparetest
  os.chdir(os.path.normpath(current_dir + "/../trunk"))
  os.system("svn up")
  os.chdir(current_dir)
  preparetest.main()

  if not( os.path.isdir(target_dir) ):
    help_exit("given foldername is not a directory")

  #change to target directory and clean up the target directory folder
  os.chdir(target_dir)

  files_to_remove = glob.glob("*")

  for f in files_to_remove:
    if os.path.isdir(f):
      shutil.rmtree(f)
    else:
      os.remove(f)

  os.chdir(current_dir)
  
  #the next few lines is necessary unless the file is manually copied over
  preparetest.copy_to_target("../trunk/integrationtests/monitor_scripts/*", target_dir)
  preparetest.copy_to_target("../trunk/integrationtests/common/*", target_dir)
  
  #change directory to the target directory and preprocess the *.mix files
  os.chdir(target_dir)
  preparetest.process_mix("repypp.py")
  

  #check to see if cron setup was requested, if yes run cron_setup
  if cron_setup:

    #create the absolute path for the log file and the file needed for the 
    #cron job
    cron_tab_dir=os.path.normpath(current_dir + "/" + target_dir)
    cron_log_dir=os.path.normpath(current_dir + "/" + log_dir)
    
    #sets up different cron tab depending on which machine this deployment script is running on. specified by the option -cseattle and -cseattlegeni
    if setup_seattle:
      cron_line="*/15 * * * * export GMAIL_USER='******' && export GMAIL_PWD='repyrepy' && /usr/bin/python " + cron_tab_dir + "/monitor_processes.py -seattle > " + cron_log_dir + "/seattlecron_log.monitor_processes" + os.linesep
	 
    elif setup_seattlegeni:
      cron_line="*/15 * * * * export GMAIL_USER='******' && export GMAIL_PWD='repyrepy' && /usr/bin/python " + cron_tab_dir + "/monitor_processes.py -seattlegeni >> " + cron_log_dir + "/seattlecron_log.monitor_processes 2>&1" + os.linesep
	  
    #setup the cron job
    setup_crontab.add_crontab(cron_line, "monitor_processes")
示例#4
0
def main():
    """
  <Purpose>
    Deploys the opendhtputget.py along with all the files needed into a
    single directory. The directory must already exist.

  <Exceptions>
    If OS is not Linux, then setting up crontab will not work.

  <Side Effect>
    If the target directory that the user provides is not empty, then this script will delete all the files
    that already exist in that directory.
	
  <Usage>
    make a folder that lies in the same directory as the trunk director and copy this file and setup_crontab.py in that file. Go to the trunk folder in the svn checkout directory and run the command: python preparetest.py <../folder_name>. Then copy over preparetest.py in that folder as well.  
    PYTHONPATH=$PYTHONPATH:/home/<user_name>/trunk && deploy_opendhtputget.py <target_folder>

  """

    checkArgs()

    #setup some variables for cron setup
    cron_setup = False
    log_dir = ""

    # -c means we have to setup the crontab with a new cron job
    if sys.argv[1] == '-c':
        cron_setup = True
        sys.argv = sys.argv[1:]
        checkArgs(cron_setup)
        log_dir = sys.argv[2]

        if not (os.path.isdir(log_dir)):
            help_exit("given log_foldername is not a directory")

    #set up all the variables about directory information
    current_dir = os.getcwd()

    #ensures that the backslashes and forward slashes are proper for the OS
    target_dir = os.path.normpath(sys.argv[1])

    #make sure svn is up to date and start up preparetest
    os.chdir(os.path.normpath(current_dir + "/../trunk"))
    os.system("svn up")
    os.chdir(current_dir)
    preparetest.main()

    if not (os.path.isdir(target_dir)):
        help_exit("given foldername is not a directory")

    #change to target directory and clean up the target directory folder
    os.chdir(target_dir)

    files_to_remove = glob.glob("*")

    for f in files_to_remove:
        if os.path.isdir(f):
            shutil.rmtree(f)
        else:
            os.remove(f)

    os.chdir(current_dir)

    #copy necessary files over
    #an alternative to the copy_to_target code, is to manually copy these two files over
    preparetest.copy_to_target("../trunk/repy/*", target_dir)
    preparetest.copy_to_target("../trunk/nodemanager/*", target_dir)
    preparetest.copy_to_target("../trunk/portability/*", target_dir)
    preparetest.copy_to_target("../trunk/seattlelib/*", target_dir)
    preparetest.copy_to_target("../trunk/seash/*", target_dir)
    preparetest.copy_to_target("../trunk/softwareupdater/*", target_dir)
    preparetest.copy_to_target("../trunk/autograder/nm_remote_api.mix",
                               target_dir)
    preparetest.copy_to_target("../trunk/keydaemon/*", target_dir)

    #the next few lines is necessary unless the file is manually copied over
    preparetest.copy_to_target("../trunk/integrationtests/opendhtputget/*",
                               target_dir)
    preparetest.copy_to_target("../trunk/integrationtests/common/*",
                               target_dir)

    #change directory to the target directory and preprocess the *.mix files
    os.chdir(target_dir)
    preparetest.process_mix(current_dir + "/repypp.py")

    #check to see if cron setup was requested, if yes run cron_setup
    if cron_setup:

        #create the absolute path for the log file and the file needed for the
        #cron job
        cron_tab_dir = os.path.normpath(current_dir + "/" + target_dir)
        cron_log_dir = os.path.normpath(current_dir + "/" + log_dir)

        cron_line = "30 * * * * export GMAIL_USER='******' && export GMAIL_PWD='repyrepy' && /usr/bin/python " + cron_tab_dir + "/opendhtputget.py >> " + cron_log_dir + "/cron_log.opendhtputget 2>&1" + os.linesep

        #setup the cron job
        setup_crontab.add_crontab(cron_line, "opendhtputget")