Exemplo n.º 1
0
    def _InitDefaults(self):
        # Default value; user may unset it.
        # $ echo -n "$IFS" | python -c 'import sys;print repr(sys.stdin.read())'
        # ' \t\n'
        SetGlobalString(self, 'IFS', split.DEFAULT_IFS)
        SetGlobalString(self, 'PWD', posix.getcwd())

        # NOTE: Should we put these in a namespace for Oil?
        SetGlobalString(self, 'UID', str(posix.getuid()))
        SetGlobalString(self, 'EUID', str(posix.geteuid()))

        SetGlobalString(self, 'HOSTNAME', str(libc.gethostname()))

        # In bash, this looks like 'linux-gnu', 'linux-musl', etc.  Scripts test
        # for 'darwin' and 'freebsd' too.  They generally don't like at 'gnu' or
        # 'musl'.  We don't have that info, so just make it 'linux'.
        SetGlobalString(self, 'OSTYPE', str(posix.uname()[0].lower()))

        # For getopts builtin
        SetGlobalString(self, 'OPTIND', '1')

        # For xtrace
        SetGlobalString(self, 'PS4', '+ ')

        # bash-completion uses this.  Value copied from bash.  It doesn't integrate
        # with 'readline' yet.
        SetGlobalString(self, 'COMP_WORDBREAKS', util.READLINE_DELIMS)
Exemplo n.º 2
0
def main(argv):
    try:
        try:
            opts, args = getopt.getopt(argv[1:], "h", ["help"])
        except getopt.error, msg:
            raise Usage(msg)

        for opt, arg in opts:
            if opt in ("-h", "--help"):
                print __doc__
                return 0

        if args:
            mp3_target_path = args.pop()
        else:
            raise Usage('no mp3 target directory given')

        if not which('lame'):
            LOGGER.fatal("Cannot find lame. Please install lame: http://lame.sourceforge.net/")
            return 3
        if not which('flac'):
            LOGGER.fatal("Cannot find flac. Please install flac: http://flac.sourceforge.net/")
            return 3

        run(mp3_target_path, getcwd(), *args)
        LOGGER.info('transcoding done, exiting normally')
        return 0
Exemplo n.º 3
0
def abspath(path):
    # type: (str) -> str
    """Return an absolute path."""
    if not isabs(path):
        cwd = posix.getcwd()
        path = join(cwd, path)
    return normpath(path)
Exemplo n.º 4
0
Arquivo: cdf.py Projeto: akrherz/pals
def Main():
	localfile = open('/home/www/pals/html/dowser/html/cdf.txt','w')
	comp = localfile.read()
	files = posix.listdir('/home/www/pals/html/dowser/')
	os.chdir('/home/www/pals/html/dowser/')
	dirs = []
	paths = []
	for i in range(len(files)):
		file = files[i]
		if posixpath.isdir(file):
			os.chdir('/home/www/pals/html/dowser/'+file+'/')		
			hello = posix.getcwd()
			refs = posix.listdir(hello)
			for it in range(len(refs)):
				ref = refs[it]
				paths.append(hello+"/"+ref)
			os.chdir('/home/www/pals/html/dowser/')	
	
	
	print comp
	for i in range(len(paths)):
		path = paths[i]
		localfile.write(path+"\n")
	localfile.close()
	print "Files in dowser updated"
Exemplo n.º 5
0
 def entry_point(argv):
      exit_code = 0
      #  TODO: resolve symlinks etc
      sys.executable = abspath(pathjoin(getcwd(),argv[0]))
      sys.argv = argv
      try:
          main()
      except SystemExit, e:
          exit_code = _exit_code[0]
Exemplo n.º 6
0
 def entry_point(argv):
     exit_code = 0
     #  TODO: resolve symlinks etc
     sys.executable = abspath(pathjoin(getcwd(), argv[0]))
     sys.argv = argv
     try:
         main()
     except SystemExit, e:
         exit_code = _exit_code[0]
Exemplo n.º 7
0
def organizeDocuments():
    print(getcwd())
    os.chdir('Documents')
    path = getcwd()
    for item in os.scandir():
        filePath = Path(item)
        if (filePath.is_dir()):
            continue
        directory = ""
        if (filePath.name.lower().__contains__("cover letter")):
            directory += "Job Apps/Cover Letter"
        elif (filePath.name.lower().__contains__("resume")):
            directory += "Job Apps/Resumes"
        else:
            directory += "Misc."
        directoryPath = Path(directory)
        filePath.rename(directoryPath.joinpath(filePath))
    for item in os.scandir():
        print(item.name)
Exemplo n.º 8
0
def main(stdscr):
    """main()
	This will be called by curses.wrapper() so 
	that the program will exit properly.
	Be sure to use the stdscr that is sent to this function
	via the wrapper() function or else the keys won't work
	properly.
	"""
    global g_selected_txt

    # Read command-line options
    # I AM NOT USING COMMAND LINE OPTION YET
    try:
        optlist, args = getopt.getopt(sys.argv[1:] \
         ,"vh", ["verbose", "help"])
    except (getopt.GetoptError, err):
        print(str(err))
        usage()
        sys.exit(12)
    #
    for o, a in optlist:
        if (o in ("-h", "--help")):
            usage()
            sys.exit()
        elif (o in ("-v", "--verbose")):
            g_debug_level = 6

    #
    # Load options from ~/.dfconfig
    load_options()
    #
    stdscr.clear()
    curses.noecho()
    stdscr.keypad(1)  #allos some escapekeys?
    curses.meta(1)  # allow 8-bit characters
    #curses.start_color()# wrapper() should start color
    #
    #
    the_path = posix.getcwd()
    code = 1
    while code in [1, 2]:
        # A code of 1 means to list the new directory
        # and wait for the user to select a file
        # or directory.
        # A code of 2 means to open a shell at the
        # specified directory.
        (l, fmt) = list_files(the_path)
        # Instantiate the main object and then run it
        w = SelectionWindow(stdscr, 0, 1, l, fmt, the_path)
        (code, the_path) = w.key_loop()
    g_selected_txt = the_path

    # Returning a text value to curses.wrapper()
    # does nothing, so just return zero.
    return (0)
Exemplo n.º 9
0
Arquivo: df.py Projeto: nikisix/df
def main(stdscr):
	"""main()
	This will be called by curses.wrapper() so 
	that the program will exit properly.
	Be sure to use the stdscr that is sent to this function
	via the wrapper() function or else the keys won't work
	properly.
	"""	
	global g_selected_txt

	# Read command-line options
	# I AM NOT USING COMMAND LINE OPTION YET
	try:
		optlist, args = getopt.getopt(sys.argv[1:] \
			,"vh", ["verbose", "help"])
	except (getopt.GetoptError, err):
		print(str(err))
		usage()
		sys.exit(12)
	#
	for o, a in optlist:
		if (o in ("-h", "--help")):
			usage()
			sys.exit()
		elif (o in ("-v", "--verbose")):
			g_debug_level = 6

	#
	# Load options from ~/.dfconfig
	load_options()
	#
	stdscr.clear()
	curses.noecho()
	stdscr.keypad(1)#allos some escapekeys?
	curses.meta(1)# allow 8-bit characters
	#curses.start_color()# wrapper() should start color
	#
	#
	the_path = posix.getcwd()
	code = 1
	while code in [1, 2]:
		# A code of 1 means to list the new directory
		# and wait for the user to select a file
		# or directory.
		# A code of 2 means to open a shell at the
		# specified directory.
		(l, fmt) = list_files(the_path)
		# Instantiate the main object and then run it
		w = SelectionWindow(stdscr, 0, 1, l, fmt, the_path)
		(code, the_path) = w.key_loop()
	g_selected_txt = the_path

	# Returning a text value to curses.wrapper()
	# does nothing, so just return zero.
	return(0)
Exemplo n.º 10
0
 def abspath(path):
     path = pathjoin(getcwd(),path)
     components_in = path.split(SEP)
     components = [components_in[0]]
     for comp in components_in[1:]:
         if not comp or comp == ".":
             pass
         elif comp == "..":
             components.pop()
         else:
             components.append(comp)
     return SEP.join(components)
Exemplo n.º 11
0
 def abspath(path):
     path = pathjoin(getcwd(), path)
     components_in = path.split(SEP)
     components = [components_in[0]]
     for comp in components_in[1:]:
         if not comp or comp == ".":
             pass
         elif comp == "..":
             components.pop()
         else:
             components.append(comp)
     return SEP.join(components)
Exemplo n.º 12
0
def abspath(path):
    """Absolute-ize and normalise the given path."""
    path = pathjoin(getcwd(),path)
    components_in = path.split(SEP)
    components = [components_in[0]]
    for comp in components_in[1:]:
        if not comp or comp == ".":
            pass
        elif comp == "..":
            components.pop()
        else:
            components.append(comp)
    return SEP.join(components)
Exemplo n.º 13
0
def abspath(path):
    """Absolute-ize and normalise the given path."""
    path = pathjoin(getcwd(), path)
    components_in = path.split(SEP)
    components = [components_in[0]]
    for comp in components_in[1:]:
        if not comp or comp == ".":
            pass
        elif comp == "..":
            components.pop()
        else:
            components.append(comp)
    return SEP.join(components)
Exemplo n.º 14
0
def get_trigrams():
    from string import *
    import analyser.settings
    STAT_DIR = getattr(analyser.settings, 'LID_STAT_FOLDER', getcwd())
    x = 'ru.dat'
    modelfile = file(os.path.join(STAT_DIR,x))
    model = Trigrams()
    for line in modelfile:
        tokens = line.split()
        if len(tokens) == 2:
            trigram = lower( unicode( tokens[0],'utf-8') )
            probability = float(tokens[1])
            model.add_trigram(trigram,probability)
    return model
Exemplo n.º 15
0
Arquivo: state.py Projeto: bsa3/oil
    def _InitDefaults(self):
        # Default value; user may unset it.
        # $ echo -n "$IFS" | python -c 'import sys;print repr(sys.stdin.read())'
        # ' \t\n'
        SetGlobalString(self, 'IFS', split.DEFAULT_IFS)
        SetGlobalString(self, 'PWD', posix.getcwd())

        # NOTE: Should we put these in a namespace for Oil?
        SetGlobalString(self, 'UID', str(posix.getuid()))
        SetGlobalString(self, 'EUID', str(posix.geteuid()))
        # For getopts builtin
        SetGlobalString(self, 'OPTIND', '1')

        # For xtrace
        SetGlobalString(self, 'PS4', '+ ')

        # bash-completion uses this.  Value copied from bash.  It doesn't integrate
        # with 'readline' yet.
        SetGlobalString(self, 'COMP_WORDBREAKS', util.READLINE_DELIMS)
Exemplo n.º 16
0
class split_data_set:

    dir = getcwd()
    image_dir = dir + "/JPEGImages"

    f_val = open("models/box_test.txt", 'w')
    f_train = open("models/box_train.txt", 'w')

    path, dirs, files = next(os.walk(image_dir))
    data_size = len(files)

    ind = 0
    data_test_size = int(0.1 * data_size)
    test_array = random.sample(range(data_size), k=data_test_size)

    for f in os.listdir(image_dir):
        if (f.split(".")[1] == "jpg"):
            ind += 1

            if ind in test_array:
                f_val.write(image_dir + '/' + f + '\n')
            else:
                f_train.write(image_dir + '/' + f + '\n')
Exemplo n.º 17
0
# Utility function to read the README file.
# Used for the long_description.  It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
    return open(os.path.join(os.path.dirname(__file__), fname)).read()


version = new_module("version")

exec(
    compile(
        open(
            path.join(
                path.dirname(globals().get(
                    "__file__", path.join(getcwd(), "circuits_minpor"))),
                "circuits_minpor/version.py"), "r").read(),
        "circuits_minpor/version.py", "exec"), version.__dict__)

setup(
    name="circuits-minpor",
    version=version.version,
    author="Michael N. Lipp",
    author_email="*****@*****.**",
    description=("A minimal portal based on the circuits component library."),
    license="GPL",
    keywords="circuits portal",
    url="http://packages.python.org/circuits-minpor",
    long_description=read('pypi-overview.rst'),
    data_files=[('', ['pypi-overview.rst'])],
    classifiers=[
Exemplo n.º 18
0
# Used for the long_description.  It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
    return open(os.path.join(os.path.dirname(__file__), fname)).read()

version = new_module("version")

exec(
    compile(
        open(
            path.join(
                path.dirname(
                    globals().get(
                        "__file__",
                        path.join(getcwd(), "circuits_minpor")
                    )
                ),
                "circuits_minpor/version.py"
            ),
            "r"
        ).read(),
        "circuits_minpor/version.py", "exec"
    ),
    version.__dict__
)

setup(
    name = "circuits-minpor",
    version = version.version,
    author = "Michael N. Lipp",
Exemplo n.º 19
0
# Used for the long_description.  It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
    return open(os.path.join(os.path.dirname(__file__), fname)).read()

version = new_module("version")

exec(
    compile(
        open(
            path.join(
                path.dirname(
                    globals().get(
                        "__file__",
                        path.join(getcwd(), "circuits_bricks")
                    )
                ),
                "circuits_bricks/version.py"
            ),
            "r"
        ).read(),
        "circuits_bricks/version.py", "exec"
    ),
    version.__dict__
)

setup(
    name = "circuits-bricks",
    version = version.version,
    author = "Michael N. Lipp",
Exemplo n.º 20
0
 def setUpClass(cls):
     file = open(path.join(getcwd(), "test", "resources", "pavilion.html"), "r")
     html = file.read()
     cls.ranking = parse_pavilion(html)
     file.close()
Exemplo n.º 21
0
def test_parse_team_id_parses_id():
    file = open(path.join(getcwd(), "test", "resources", "squad.html"), "r")
    html = file.read()
    teamID = parse_team_id(html)
    assert_equal(teamID, 30438)
Exemplo n.º 22
0
# Utility function to read the README file.
# Used for the long_description.  It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
    return open(os.path.join(os.path.dirname(__file__), fname)).read()


version = new_module("version")

exec(
    compile(
        open(
            path.join(
                path.dirname(globals().get(
                    "__file__", path.join(getcwd(), "circuits_bricks"))),
                "circuits_bricks/version.py"), "r").read(),
        "circuits_bricks/version.py", "exec"), version.__dict__)

setup(
    name="circuits-bricks",
    version=version.version,
    author="Michael N. Lipp",
    author_email="*****@*****.**",
    description=(
        "General purpose components extending the circuits framework."),
    license="MIT",
    keywords="circuits component",
    url="http://packages.python.org/circuits-bricks",
    long_description=read('pypi-overview.rst'),
    classifiers=[
Exemplo n.º 23
0
'''
Created on May 2, 2019

@author: Riggs-MAC
'''
from posix import getcwd
from GroundSystem import TLMFileRead

TLMFileRead.TLMFileRead()

print(getcwd())
Exemplo n.º 24
0
 def setUpClass(cls):
     file = open(path.join(getcwd(), "test", "resources", "squad.html"), "r")
     html = file.read()
     cls.players = parse_players(html)
     cls.p = cls.players[0]
     file.close()
Exemplo n.º 25
0
4.5 AFT IRDT
3.5 IRST
-2.5 HAT NDT
-3.5 HNT NST NT
-4.5 HLV VET
-9.5 MART MIT'''

tzd = {}
for tz_descr in map(str.split, tz_str.split('\n')):
    tz_offset = int(float(tz_descr[0]) * 3600)
    for tz_code in tz_descr[1:]:
        tzd[tz_code] = tz_offset

if '__main__' == __name__:
    filenames = [ ]
    for f in listdir(getcwd()):
         if isfile(join(getcwd(),f)):
             if f.split(".")[-1] == 'log':
                 filenames.append(f)
    last_timestamp = dict()
    counter = {f:0 for f in filenames}
    errors = []
    max_lag = 0
    window_start = datetime.now(tzlocal()) + timedelta(days=-100)
    linebuffer = ''
    for line in fileinput.input():
        if line != '\n':
            linebuffer += line
        else:
            if linebuffer.strip():
                continue
Exemplo n.º 26
0
Arquivo: state.py Projeto: bsa3/oil
 def Reset(self):
     del self.stack[:]
     self.stack.append(posix.getcwd())
Exemplo n.º 27
0
        # dirt hack @todo need to get cv.SetCaptureProperty to work
        for j in range(fpm):
            cv.QueryFrame(capture)
    else:
        cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_POS_FRAMES, fpm * i)

    img = cv.QueryFrame(capture)
    if img:
        cv.SaveImage('sample_images/%s.png' % i, img)
        cv.WaitKey(fpm)
        i += 1


colours = []
# get all the image
images = glob("%s/sample_images/*.png" % getcwd())
# process images
for image in images:
    # open the image
    im = Image.open(image)
    im = im.resize((150, 150))
    # get PIL image
    ar = scipy.misc.fromimage(im)
    shape = ar.shape
    ar = ar.reshape(scipy.product(shape[:2]), shape[2])

    codes, dist = scipy.cluster.vq.kmeans(ar, NUM_CLUSTERS)

    vecs, dist = scipy.cluster.vq.vq(ar, codes)         # assign codes
    counts, bins = scipy.histogram(vecs, len(codes))    # count occurrences