Пример #1
0

"""
   Obtain GitHub username & password from config file
"""
parser = SafeConfigParser()
parser.read("orgman.conf")

githubUsername = parser.get("github", "username")
githubPassword = parser.get("github", "password")

"""
    Get commandline arguments
"""
parser = argparse.ArgumentParser()
parser.add_argument("org", help="name of GitHub organization", type=str) # Organization Name
subParser = parser.add_subparsers(help="commands")

# List Commands
listParser = subParser.add_parser("list", help="List details of specified attribute")
listParser.add_argument("-p", "--profile", help="generate an organization/team profile", action="store_true", dest="listProfile")
listParser.add_argument("-t", "--team", help="list team(s)", metavar="team_id", nargs="*", dest="listTeamID")
listParser.add_argument("-m", "--member", help="list member(s)", metavar="member_id", nargs="*", dest="listMemberID")
listParser.add_argument("-s", "--repos", help="list repos", action="store_true", dest="listRepos")

# Add Commands
addParser = subParser.add_parser("add", help="Add resources to specified organization")
addParser.add_argument("-p", "--profile", help="use an org profile to perform add operations", nargs=1, dest="addProfile")
addParser.add_argument("-r", "--repo", help="perform operations on repositories", nargs=1, dest="addRepo")
addParser.add_argument("-t", "--team", help="perform operations on teams", nargs=1, dest="addTeam")
addParser.add_argument("-e", "--perm", help="level of permission", choices=["pull", "push", "admin"], dest="addPerm", default="pull")
Пример #2
0
def main():
    configfile = "~/.firefoxsyncrc"
    import ConfigParser
    import argparse
    import getpass
    import time
    import sys
    from os import path
    from ConfigParser import SafeConfigParser

    configfile = path.expanduser(configfile)
    parser = SafeConfigParser()
    parser.read(configfile)
    try:
        username = parser.get('server_settings', 'username')
    except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
        username = raw_input('Username: '******'server_settings', 'password')
    except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
        password = getpass.getpass('Password (for the server): ')
    try:
        passphrase = parser.get('server_settings', 'passphrase')
    except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
        passphrase = getpass.getpass('Passphrase (for decryption): ')
    try:
        server = parser.get('server_settings', 'server')
    except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
        server = "https://auth.services.mozilla.com"

    parser = argparse.ArgumentParser(
            description="prints urls stored in FirefoxSync (Weave)")
    parser.add_argument("-t", "--time", action="store", dest="time",
                help="print all URLs since this (POSIX) time (as POSIX)")
    parser.add_argument('-d', action='store_true', dest='daemon_mode',
            default=False, help='keep running and check for new history items \
            every ten minutes')
    parser.add_argument('-n', action='store_true', dest='now',
            default=False, help='print history from now (only makes sense \
                    with -d')
    parser.add_argument('--delete-tabs', action='store_true', dest='dtabs',
            default=False, help='presents user with list of computers with \
                    synced tabs, ask user which to delete and deletes it')
    args = parser.parse_args()

    syncer = SyncSample(username, password, passphrase, server=server)
    meta = syncer.get_meta()
    assert meta['storageVersion'] == 5

    since_time = args.time
    if args.now:
        since_time = time.time()

    sleeptime = 600
    if args.dtabs:
        syncer.delete_tabs()
        sys.exit()
    elif args.daemon_mode:
        while 1:
            last_time = time.time()
            ids = syncer.history(since_time)
            for one_id in ids:
                print(syncer.hist_item(one_id)[u'histUri'])
            del syncer
            time.sleep(sleeptime)
            since_time = last_time
    else:
        ids = syncer.history(since_time)
        for one_id in ids:
            print(syncer.hist_item(one_id)[u'histUri'])
Пример #3
0
        description="""

        Copies the output ascii spectra to the iPTF marshal

        Checks to be sure spectra have quality > 3 and only
        copies spectra for objects with "PTF" prefix.

        Specify input directory with -d, or --specdir parameters.
        If none specified, use current date directory in _reduxpath

        """,
        formatter_class=argparse.RawTextHelpFormatter)

    parser.add_argument('-d',
                        '--specdir',
                        type=str,
                        dest="specdir",
                        help='Directory with output PTF*_SEDM.txt files.',
                        default=None)

    args = parser.parse_args()

    specdir = args.specdir
    print "Directory where reduced spectra reside: ", specdir

    if specdir is None:
        timestamp = datetime.datetime.isoformat(datetime.datetime.utcnow())
        timestamp = timestamp.split("T")[0].replace("-", "")
        specdir = os.path.join(_reduxpath, timestamp)
    else:
        specdir = os.path.abspath(specdir)
        timestamp = os.path.basename(specdir)
Пример #4
0
    return result


# Tell the parser which ini file to read
parser = SafeConfigParser()
parser.read("api-keys.ini")

# Read in the OAuth2 keys, secrets, and tokens for authentications
consumer_key = parser.get("API_KEYS", "consumer_key")
consumer_secret = parser.get("API_KEYS", "consumer_secret")
access_token = parser.get("API_KEYS", "access_token")
access_token_secret = parser.get("API_KEYS", "access_token_secret")

# Command-line argument parsing
parser = argparse.ArgumentParser()
parser.add_argument("-hashtag", help="Unfollow users", action="store", type=str)
parser.add_argument("-add", help="Follow users", action="store_true")
parser.add_argument("-delete", help="Unfollow users", action="store_true")
args = parser.parse_args()

# Authenticate with twitter to use the Twitter API
api = twitter.Api(
    consumer_key=consumer_key,
    consumer_secret=consumer_secret,
    access_token_key=access_token,
    access_token_secret=access_token_secret,
)

# Query for tweets with the hashtag provided by the user
query = api.GetSearch("#" + str(args.hashtag), per_page=50)
Пример #5
0
    parser = argparse.ArgumentParser(description=\
        '''

        Runs astrometry.net on the image specified as a parameter and returns 
        the offset needed to be applied in order to center the object coordinates 
        in the reference pixel.
           
        -i image
        -b It is AB shot.
        -a Astrometry is needed.
        -p plot results.
        ''', formatter_class=argparse.RawTextHelpFormatter)

    parser.add_argument('-i',
                        '--image',
                        type=str,
                        dest="image",
                        help='Fits file with acquisition image.')
    parser.add_argument('-b',
                        '--isAB',
                        action='store_true',
                        dest="isAB",
                        default=False,
                        help='Whether we need A, B pair pointing or only A.')
    parser.add_argument(
        '-a',
        '--astro',
        action='store_true',
        dest="astro",
        default=False,
        help='Whether we need to solve the astrometry for the image.')
Пример #6
0
    plt.savefig(statfile.replace(".log", "%s.png" % (day)), bbox="tight")


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description=\
        '''

        Runs astrometry.net on the image specified as a parameter and returns 
        the offset needed to be applied in order to center the object coordinates 
        in the reference pixel.
            
        ''', formatter_class=argparse.RawTextHelpFormatter)

    parser.add_argument('-d',
                        '--photdir',
                        type=str,
                        dest="photdir",
                        help='Fits directory file with tonight images.',
                        default=None)

    args = parser.parse_args()

    photdir = args.photdir
    print "Parameter directory where stats are run : %s." % photdir

    if (photdir is None):
        timestamp = datetime.datetime.isoformat(datetime.datetime.utcnow())
        timestamp = timestamp.split("T")[0].replace("-", "")
        photdir = os.path.join(_photpath, timestamp)
        print "New directory %s" % photdir
    else:
        timestamp = os.path.basename(os.path.abspath(photdir))
Пример #7
0
    uplimmag = zp - 2.5*np.log10(rmsflux) + 2.5*np.log10(f['itime'])
    
    return uplimmag
        
if __name__ == '__main__':
    parser = argparse.ArgumentParser(description=\
        '''

        Runs astrometry.net on the image specified as a parameter and returns 
        the offset needed to be applied in order to center the object coordinates 
        in the reference pixel.
            
        ''', formatter_class=argparse.RawTextHelpFormatter)


    parser.add_argument('-d', '--reddir', type=str, dest="reduced", help='Fits directory file with reduced images.', default=None)

    args = parser.parse_args()
    
    reduced = args.reduced
    
    if (reduced is None):
        timestamp=datetime.datetime.isoformat(datetime.datetime.utcnow())
        timestamp = timestamp.split("T")[0].replace("-","")
        reduced = os.path.join(_photpath, timestamp, "reduced")


    os.chdir(reduced)
    

    for f in glob.glob("*.fits"):
Пример #8
0

def php_add_to_array(ent, ch, target_file):
    ch = escape(ch)
    ch = ch.encode('utf-8')
    target_file.write('\'' + ent.encode('utf-8') + "\' => '" + ch + "',\n")


def php_close_array(target_file):
    target_file.write("];\n")


if __name__ == "__main__":
    # Read command line input parameters
    parser = argparse.ArgumentParser()
    parser.add_argument('locale_repo', help='Path to locale files')
    parser.add_argument('reference_repo', help='Path to reference files')
    parser.add_argument('locale_code', help='Locale language code')
    parser.add_argument('reference_code', help='Reference language code')
    parser.add_argument('repository', help='Repository name')
    args = parser.parse_args()

    exclusionlist = ['.hgtags', '.hg', '.git', '.gitignore']
    dirs_locale = os.listdir(args.locale_repo)
    if args.repository.startswith('gaia') or args.repository == 'l20n_test':
        dirs_reference = os.listdir(args.reference_repo)
        dirs_reference = [x for x in dirs_reference if x not in exclusionlist]
    else:
        dirs_reference = [
            "browser", "calendar", "chat", "devtools", "dom", "editor",
            "extensions", "mail", "mobile", "netwerk", "other-licenses",
Пример #9
0
        nfiles = nfilesnew


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description=\
        '''

        Runs astrometry.net on the image specified as a parameter and returns 
        the offset needed to be applied in order to center the object coordinates 
        in the reference pixel.
            
        ''', formatter_class=argparse.RawTextHelpFormatter)

    parser.add_argument('-d',
                        '--photdir',
                        type=str,
                        dest="photdir",
                        help='Fits directory file with tonight images.',
                        default=None)
    parser.add_argument('-f',
                        '--fullred',
                        action='store_true',
                        dest="fullred",
                        default=False,
                        help='Whether we should do a full reduction.')
    parser.add_argument('-o',
                        '--overwrite',
                        action="store_true",
                        help='re-reduce and overwrite the reduced images?',
                        default=False)

    args = parser.parse_args()
Пример #10
0
def php_header(target_file):
    target_file.write("<?php\n$tmx = [\n")

def php_add_to_array(ent,ch,target_file):
    ch = escape(ch)
    ch = ch.encode('utf-8')
    target_file.write('\'' + ent.encode('utf-8') + "\' => '" + ch + "',\n")

def php_close_array(target_file):
    target_file.write("];\n")

if __name__ == "__main__":
    # Read command line input parameters
    parser = argparse.ArgumentParser()
    parser.add_argument('locale_repo', help='Path to locale files')
    parser.add_argument('reference_repo', help='Path to reference files')
    parser.add_argument('locale_code', help='Locale language code')
    parser.add_argument('reference_code', help='Reference language code')
    parser.add_argument('repository', help='Repository name')
    args = parser.parse_args()

    exclusionlist = ['.hgtags', '.hg', '.git', '.gitignore']
    dirs_locale = os.listdir(args.locale_repo)
    if args.repository.startswith('gaia') or args.repository == 'l20n_test' :
        dirs_reference = os.listdir(args.reference_repo)
        dirs_reference = [x for x in dirs_reference if x not in exclusionlist]
    else:
        dirs_reference = [
            "browser", "calendar", "chat", "devtools", "dom", "editor",
            "extensions", "mail", "mobile", "netwerk", "other-licenses",
Пример #11
0
        As an option, can run lacosmic to remove cosmic rays.
        By default it invokes astrometry.net before the reduction.
        
        %run rcred.py -d PHOTDIR 
                
        Reduced images are stored in directory called "reduced", within the main directory.
        
        Optionally, it can be used to clean the reduction products generated by this pipeline within PHOTDIR diretory using -c option (clean).
        
        %run rcred.py -d PHOTDIR -c
            
        ''', formatter_class=argparse.RawTextHelpFormatter)

    parser.add_argument('-l',
                        '--filelist',
                        type=str,
                        help='File containing the list of fits for the night.',
                        default=None)
    parser.add_argument(
        '-d',
        '--photdir',
        type=str,
        help='Directory containing the science fits for the night.',
        default=None)
    parser.add_argument('-c',
                        '--clean',
                        action="store_true",
                        help='Clean the reduced images?',
                        default=False)
    parser.add_argument('-o',
                        '--overwrite',
Пример #12
0
        interpolate_zp(reduced, "allstars_zp.log")

    clean_tmp_files()


if __name__ == "__main__":

    parser = argparse.ArgumentParser(
        description="""

        Computes the zeropoints for all the images in the folder.
            
        """,
        formatter_class=argparse.RawTextHelpFormatter,
    )

    parser.add_argument(
        "-d", "--photdir", type=str, dest="photdir", help="Fits directory file with tonight images.", default=None
    )

    args = parser.parse_args()

    photdir = args.photdir

    if photdir is None:
        timestamp = datetime.datetime.isoformat(datetime.datetime.utcnow())
        timestamp = timestamp.split("T")[0].replace("-", "")
        photdir = os.path.join("/scr2/sedm/phot/", timestamp)

    main(os.path.join(os.path.abspath(photdir), "reduced"))
Пример #13
0
import base64, json, logging, os, re, requests, socket, struct, sys, urllib2
from requests.auth import HTTPBasicAuth
import argparse
from ConfigParser import SafeConfigParser

parser = SafeConfigParser()
parser.read('/tmp/fir.conf')
#parser.read('/etc/elastalert/rules/e2hive.conf')

url = parser.get('config', 'url')
token = parser.get('config', 'token')

#logging.basicConfig(filename='/tmp/fir_incident.log',level=logging.DEBUG)

parser = argparse.ArgumentParser(description='Post an event to FIR')
parser.add_argument('-a', '--actor', help='Actor', required=False)
parser.add_argument('-c', '--category', help='Category', required=False)
parser.add_argument('-l',
                    '--confidentiality',
                    help='Confidentiality',
                    required=False)
parser.add_argument('-d', '--description', help='Description', required=True)
parser.add_argument('-t', '--detection', help='Detection', required=False)
parser.add_argument('-p', '--plan', help='Plan', required=False)
parser.add_argument('-s', '--severity', help='Severity', required=False)
parser.add_argument('-j', '--subject', help='Subject', required=True)

args = parser.parse_args()

actor = args.actor
category = args.category
Пример #14
0
       result.append(item)
   return result

# Tell the parser which ini file to read
parser = SafeConfigParser()
parser.read('api-keys.ini')

# Read in the OAuth2 keys, secrets, and tokens for authentications
consumer_key        = parser.get('API_KEYS', 'consumer_key')
consumer_secret     = parser.get('API_KEYS', 'consumer_secret')
access_token        = parser.get('API_KEYS', 'access_token')
access_token_secret = parser.get('API_KEYS', 'access_token_secret')

# Command-line argument parsing
parser = argparse.ArgumentParser()
parser.add_argument("-hashtag", help="Unfollow users", action='store', type=str)
parser.add_argument("-add", help="Follow users", action='store_true')
#parser.add_argument("-delete", help="Unfollow users", action='store_true')
args = parser.parse_args()

# Authenticate with twitter to use the Twitter API
api = twitter.Api(consumer_key=consumer_key, consumer_secret=consumer_secret, access_token_key=access_token, access_token_secret=access_token_secret)

# Query for tweets with the hashtag provided by the user
query = api.GetSearch("#" + str(args.hashtag), count=100)
# NOTE: one can follow 1000 accounts per day, limiting to 100 results grants 10 searches+autofollow per day

if args.add:
	# print args.add
	# Create a list for all the users found using the specified hashtag.
	# Interate through the list and create friendships (Follow them)
Пример #15
0
import json, urllib2, base64, requests
import requests
import argparse
import sys
from ConfigParser import SafeConfigParser

parser = SafeConfigParser()
parser.read('/etc/elastalert/rules/e2hive.conf')

url = parser.get('config', 'url')
apikey = parser.get('config', 'apikey')

sys.stdout = open('/tmp/e2hive.log', 'w')

parser = argparse.ArgumentParser(description='Post a case to the Hive')
parser.add_argument('-t', '--title', help='Title', required=True)
parser.add_argument('-d', '--description', help='Description', required=True)
parser.add_argument('-s', '--severity', help='Severity', required=False)
args = parser.parse_args()

title = args.title
description = args.description
severity = args.severity

authheader = "Bearer " + apikey
headers = {"Authorization": authheader, "Content-Type": "application/json"}

data = {"title": title, "description": description, "severity": int(severity)}

response = requests.post(url + "/api/case",
                         headers=headers,
Пример #16
0
if __name__ == '__main__':
    parser = argparse.ArgumentParser(description=\
        '''

        Runs astrometry.net on the image specified as a parameter and returns 
        the offset needed to be applied in order to center the object coordinates 
        in the reference pixel.
           
        -i image
        -b It is AB shot.
        -a Astrometry is needed.
        -p plot results.
        ''', formatter_class=argparse.RawTextHelpFormatter)


    parser.add_argument('-i', '--image', type=str, dest="image", help='Fits file with acquisition image.')
    parser.add_argument('-b', '--isAB', action='store_true', dest="isAB", default=False, help='Whether we need A, B pair pointing or only A.')
    parser.add_argument('-a', '--astro', action='store_true', dest="astro", default=False, help='Whether we need to solve the astrometry for the image.')
    parser.add_argument('-p', '--plot', action='store_true', dest="plot", default=False, help='Whether we plot the astrometry for the image.')

    
    args = parser.parse_args()
    
    infile = args.image
    isAB = args.isAB
    astro = args.astro
    plot = args.plot
    
    ret = main(infile, isAB, astro, plot)
    print ret
    logger.info("Returned from offseets with code %s"% ret[0])