def FuncFileFilter():
    baseExeFolder = 'E:\design\\test\sourcesFunction\ConsoleApplication6.exe'
    listDsmAndGmlFiles = os.listdir(baseExeFolder)
    for fileDsmOrGml in listDsmAndGmlFiles:
        #if fileDsmOrGml.split('.')[-1]=='gml':
        #    targetDirGml='G:\\design\\temp'+os.sep+fileDsmOrGml
        #    os.remove(targetDirGml)
        if fileDsmOrGml.split('.')[-1] == 'dsm':
            funcDsmFile = open(baseExeFolder + os.sep + fileDsmOrGml, "r")
            countInstr = funcDsmFile.readline().count(";")
            if countInstr <= 10:
                funcDsmFile.close()
                targetDsm = baseExeFolder + os.sep + fileDsmOrGml
                targetGml = baseExeFolder + os.sep + fileDsmOrGml.split(
                    '.')[0] + '.gml'
                os.remove(targetDsm)
                os.remove(targetGml)
            else:
                funcDsmFile.close()
        elif fileDsmOrGml.split('.')[-1] == 'gml':
            funcGmlFile = open(baseExeFolder + os.sep + fileDsmOrGml, "r")
            countTracelet = funcGmlFile.read().count('node')
            if countTracelet < 3:
                funcGmlFile.close()
                targetGml = baseExeFolder + os.sep + fileDsmOrGml
                targetDsm = baseExeFolder + os.sep + fileDsmOrGml.split(
                    '.')[0] + '.dsm'
                os.remove(targetDsm)
                os.remvoe(targetGml)
            else:
                funcGmlFile.close()
                os.remove(baseExeFolder + os.sep + fileDsmOrGml)
    return 0
Ejemplo n.º 2
0
def main():
    parser = OptionParser()

    parser.add_option('-r', dest='readsf', help='Fasta file of reads')
    parser.add_option('-n',
                      dest='numreads',
                      type='int',
                      help='Number of reads to sample for MCMC')
    parser.add_option('-k',
                      dest='clusters',
                      type='int',
                      help='Number of clusters')
    parser.add_option('-m', dest='mers', type='int', help='Mers to count')
    parser.add_option('-p',
                      dest='proc',
                      type='int',
                      help='Number of processes to run')
    parser.add_option('--em',
                      dest='soft_assign',
                      action='store_true',
                      default=False,
                      help='Use a soft assignment of reads to clusters')

    (options, args) = parser.parse_args()

    if options.soft_assign:
        em = '--em'
    else:
        em = ''

    # randomly sample reads
    total_reads = 0
    for line in open(options.readsf):
        if line[0] == '>':
            total_reads += 1
    if options.numreads and options.numreads < total_reads:
        dna.fasta_rand_big(options.numreads, options.readsf, 'sample.fa')
    else:
        if os.path.isfile('sample.fa') or os.path.islink('sample.fa'):
            os.remvoe('sample.fa')
        os.symlink(options.readsf, 'sample.fa')

    # CompostBin
    p = subprocess.Popen(
        '%s/compostbin.py -r sample.fa -c %d -k %d &> cb.log' %
        (bin_dir, options.clusters, options.mers),
        shell=True)
    os.waitpid(p.pid, 0)

    # initialize clusters
    init_clusters(options.readsf, options.clusters, options.soft_assign)

    # run seed_only
    p = subprocess.Popen(
        '%s/imm_cluster.py -k %d -r %s -p %d -s --seed_only %s >> cb.log' %
        (bin_dir, options.clusters, options.readsf, options.proc, em),
        shell=True)
    os.waitpid(p.pid, 0)
 def stop(self):
  """Stop the daemon"""
  #chkpid
  pid = self.chkpid()
  if not pid:
   message = "pidfile {0} does not exists. Daemon not running?\n".format(self.pidfile)
   sys.stderr.write(message.format(self.pidfile))
   sys.exit(1)

  try:
   while 1:
    os.kill(pid, signal.SIGTERM)
    time.sleep(0.1)
  except OSError as err:
   e = str(err.args)
   if (e.find("No such process") > 0):
    if os.path.exists(self.pidfile):
     os.remvoe(self.pidfile)
   else:
    print(str(err.args))
    sys.exit(1)
Ejemplo n.º 4
0
def main():
    parser = OptionParser()

    parser.add_option('-r', dest='readsf', help='Fasta file of reads')
    parser.add_option('-n', dest='numreads', type='int', help='Number of reads to sample for MCMC')
    parser.add_option('-k', dest='clusters', type='int', help='Number of clusters')
    parser.add_option('-m', dest='mers', type='int', help='Mers to count')
    parser.add_option('-p', dest='proc', type='int', help='Number of processes to run')
    parser.add_option('--em', dest='soft_assign', action='store_true', default=False, help='Use a soft assignment of reads to clusters')

    (options, args) = parser.parse_args()

    if options.soft_assign:
        em = '--em'
    else:
        em = ''

    # randomly sample reads
    total_reads = 0
    for line in open(options.readsf):
        if line[0] == '>':
            total_reads += 1
    if options.numreads and options.numreads < total_reads:
        dna.fasta_rand_big(options.numreads, options.readsf, 'sample.fa')
    else:
        if os.path.isfile('sample.fa') or os.path.islink('sample.fa'):
            os.remvoe('sample.fa')
        os.symlink(options.readsf, 'sample.fa')

    # CompostBin
    p = subprocess.Popen('%s/compostbin.py -r sample.fa -c %d -k %d &> cb.log' % (bin_dir, options.clusters, options.mers), shell=True)
    os.waitpid(p.pid, 0)

    # initialize clusters
    init_clusters(options.readsf, options.clusters, options.soft_assign)

    # run seed_only
    p = subprocess.Popen('%s/imm_cluster.py -k %d -r %s -p %d -s --seed_only %s >> cb.log' % (bin_dir, options.clusters, options.readsf, options.proc, em), shell=True)
    os.waitpid(p.pid, 0)
Ejemplo n.º 5
0
 def tearDown(self):
     os.remvoe(self.template_file)
     # make sure that other tests don't rely on these settings
     settings.TEMPLATE_DIRS = self.default_template_dirs
Ejemplo n.º 6
0
def render(args):
    x = args.coords[0]
    y = args.coords[1]
    z = args.coords[2]
    coordstext = "x{}y{}z{}".format(x, y, z)

    res = args.res.split("x")
    mode = args.mode
    spp = args.ssp

    folder = lapse360folder + "/" + coordstext
    files = glob.glob(folder + "/*.json")
    files.insert(0, files.pop())
    filesenum = enumerate(files)
    numfiles = len(files)
    
    for f in filesenum:
        print(f)
        start = time.time()

        # load the json, change it, and dump it again
        with open(f[1], "r") as scenefile:
            config = json.load(scenefile)

        config["sppTarget"] = spp
        config["height"] = int(res[1])
        config["width"] = int(res[0])


        name = f[1].split("/")[-1].rsplit(".", 1)[0]
        notexist = not os.path.exists(folder + "/" + name + ".octree")

        if notexist:
            snap = config["zfssnapshot"]
            pool = snap.split('/')[0]
            subprocess.call("sudo zfs destroy " + pool + "/" + coordstext, shell=True)            
            subprocess.call("sudo zfs clone -o readonly=on " + snap + " " + pool + "/" + coordstext, shell=True)

        pngfilename = "{}/{}-{}".format(folder, name, str(spp))            

        if mode == "2d":
            json.dump(config, open(f[1], "w"))
            
            command = "{} -jar {} -scene-dir {}/ -render {}".format(java, chunky, folder, name)
            subprocess.call(command, shell=True)
            subprocess.call("convert " + pngfilename  + ".png -gravity southeast -stroke '#000C' -strokewidth 2 -annotate 0 \"" + name + "\" -stroke  none -fill white -annotate 0 \"" + name + "\" " + pngfilename + "-annotated.png", shell=True)

            for each in glob.glob(folder + "/" + name + "*.dump"): os.remove(each)

            try:
                os.remove(pngfilename + ".png")
            except:
                pass

            
        if mode == "3d":

            config["camera"]["projectionMode"] = "ODS_LEFT"
            json.dump(config, open(f[1], "w"))


            command = "{} -jar {} -scene-dir {}/ -render {}".format(java, chunky, folder, name)
            subprocess.call(command, shell=True)
            subprocess.call("convert " + pngfilename  + ".png -gravity southeast -stroke '#000C' -strokewidth 2 -annotate 0 \"" + name + "\" -stroke  none -fill white -annotate 0 \"" + name + "\" " + pngfilename + "-ODS_LEFT-annotated.png", shell=True)

            for each in glob.glob(folder + "/" + name + "*.dump"): os.remove(each)

            try:
                os.remove(pngfilename + ".png")
                os.remvoe(pngfilename + "-ODS_LEFT-annotated.png")
            except:
                pass


            config["camera"]["projectionMode"] = "ODS_RIGHT"
            json.dump(config, open(f[1], "w"))


            command = "{} -jar {} -scene-dir {}/ -render {}".format(java, chunky, folder, name)
            subprocess.call(command, shell=True)
            subprocess.call("convert " + pngfilename  + ".png -gravity southeast -stroke '#000C' -strokewidth 2 -annotate 0 \"" + name + "\" -stroke  none -fill white -annotate 0 \"" + name + "\" " + pngfilename + "-ODS_RIGHT-annotated.png", shell=True)

            for each in glob.glob(folder + "/" + name + "*.dump"): os.remove(each)
            try:
                os.remove(pngfilename + ".png")
                os.remvoe(pngfilename + "-ODS_RIGHT-annotated.png")
            except:
                pass

            subprocess.call("convert " + pngfilename + "-ODS_LEFT-annotated.png " + pngfilename + "-ODS_RIGHT-annotated.png -append " + pngfilename + "-combined-annotated.png", shell=True)

            
        if notexist:
            snap = config["zfssnapshot"]
            pool = snap.split('/')[0]
            subprocess.call("sudo zfs clone -o readonly=on " + snap + " " + pool + "/" + coordstext, shell=True)



        stop = time.time()
        elapsed = stop - start



        # tell me how much more coffee I have to dring until it's done
        print("Just finished snapshot {} of {}, {} percent. {} hours left.".format( f[0] + 1, numfiles, 100.0 * (f[0] + 1) / numfiles, elapsed * (numfiles - f[0] + 1)/60/60))
def main(argv):

    #all parameter we may need
    keyFile = ''
    cerFile = ''
    keyPemFile = ''
    cerPemFile = ''
    pemFile = ''
    token = ''
    payload = '{"aps":{"alert":"default message","sound":"alert.aif"}}'
    development = 1
    generatePemFile = 0

    #parsering the arguments
    try:
         opts, args = getopt.getopt(argv,"hk:c:p:m:t:d:",["help", "keyFile=", "cerFile=", "keyPemFile=", "cerPemFile=", "pemFile=", "token=", "payload=", "development=", "generatePemFile="])
    except getopt.GetoptError:
        print ('please use iosPushNotification.py -h or iosPushNotification.py --help for help')
        sys.exit(2)
    for opt, arg in opts:
        if opt in ("-h", "--help"):
            print ("""
#######################--help--#######################
    -k --keyFile : for the p12 file.
    -c --cerFile : for the cert file.
    --keyPemFile : for pem file that generated from the p12 file.
    --cerPemFile : for pem file that generated from the cert file.
    --pemFile : the combined pem file, which is most widely used.
    -t --token : the token of device to receive this notification.
    -m --payload : the payload or the file path of payload to be sent.
    -d --development : specified as 1 to send push notificaiont to staging server, 0 to send to produciton server, default as 1.
    --generatePemFile : generate the pem file, name it as same as keyFile's name
#####################################################
            """)
            sys.exit()
        elif opt in ("-k", "--keyFile"):
            keyFile = arg
        elif opt in ("-c", "--cerFile"):
            cerFile = arg
        elif opt == "--keyPemFile":
            keyPemFile = arg
        elif opt == "--cerPemFile":
            cerPemFile = arg
        elif opt in ("-p", "--pemFile"):
            pemFile = arg
        elif opt in ("-t", "--token"):
            token = arg
        elif opt in ("-m", "--payload"):
            payload = arg
        elif opt in ("-d", "--development"):
            development = arg
        elif opt in ("--generatePemFile"):
            generatePemFile = arg

    if (os.path.isfile(payload)):
        payload = open(payload, "r").read()
    payload = json.dumps(json.JSONDecoder().decode(payload))
    print payload
    # checking necessary paramenters
    if not token:
        print ('token is needed to send a push notification, pealse specified with ')
        sys.exit(2)
    hasPem = keyFile or (keyPemFile and cerPemFile) or pemFile
    if not hasPem:
        print ('key file and cert file is needed, you need to provided either original files or pem file')
        sys.exit(2)

    #sending push notification
    if pemFile :
        send_push_notification(token, payload, pemFile, dev = development == 1)
    elif keyPemFile and cerPemFile :
        pemFile = create_pem_file(keyPemFile, cerPemFile)
        send_push_notification(token, payload, pemFile, dev = development == 1)
        os.remvoe(pemFile)
    elif keyFile :
        pemFile = create_pem_file(keyFile, cerFile)
        send_push_notification(token, payload, pemFile, dev = development == 1)
        if (generatePemFile):
            fileName = keyFile[:-4] + ".pem"
            print (fileName)
            os.rename(pemFile, fileName)
        else :
            os.remove(pemFile)
Ejemplo n.º 8
0
 def tearDown(self):
     os.remvoe(self.template_file)
     # make sure that other tests don't rely on these settings
     settings.TEMPLATE_DIRS = self.default_template_dirs