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)
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
def abspath(path): # type: (str) -> str """Return an absolute path.""" if not isabs(path): cwd = posix.getcwd() path = join(cwd, path) return normpath(path)
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"
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]
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]
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)
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)
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)
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)
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)
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)
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)
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
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)
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')
# 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=[
# 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",
# 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",
def setUpClass(cls): file = open(path.join(getcwd(), "test", "resources", "pavilion.html"), "r") html = file.read() cls.ranking = parse_pavilion(html) file.close()
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)
# 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=[
''' Created on May 2, 2019 @author: Riggs-MAC ''' from posix import getcwd from GroundSystem import TLMFileRead TLMFileRead.TLMFileRead() print(getcwd())
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()
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
def Reset(self): del self.stack[:] self.stack.append(posix.getcwd())
# 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