Python os.devnull() Examples
The following are 30
code examples of os.devnull().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os
, or try the search function
.
Example #1
Source File: notify.py From wechat-alfred-workflow with MIT License | 7 votes |
def convert_image(inpath, outpath, size): """Convert an image file using ``sips``. Args: inpath (str): Path of source file. outpath (str): Path to destination file. size (int): Width and height of destination image in pixels. Raises: RuntimeError: Raised if ``sips`` exits with non-zero status. """ cmd = [ b'sips', b'-z', str(size), str(size), inpath, b'--out', outpath] # log().debug(cmd) with open(os.devnull, 'w') as pipe: retcode = subprocess.call(cmd, stdout=pipe, stderr=subprocess.STDOUT) if retcode != 0: raise RuntimeError('sips exited with %d' % retcode)
Example #2
Source File: config.py From ciftify with MIT License | 6 votes |
def get_git_log(git_dir, file_name=None): git_cmd = ["cd {}; git log".format(git_dir)] if file_name: git_cmd.append("--follow {}".format(file_name)) git_cmd.append("| head") git_cmd = " ".join(git_cmd) # Silence stderr try: with open(os.devnull, 'w') as DEVNULL: file_log = util.check_output(git_cmd, stderr=DEVNULL) except subprocess.CalledProcessError: # Fail safe in git command returns non-zero value logger = logging.getLogger(__name__) logger.error("Unrecognized command: {} " "\nReturning empty git log.".format(git_cmd)) file_log = "" return file_log
Example #3
Source File: epr.py From epr with MIT License | 6 votes |
def loadstate(): global STATE, STATEFILE if os.getenv("HOME") is not None: STATEFILE = os.path.join(os.getenv("HOME"), ".epr") if os.path.isdir(os.path.join(os.getenv("HOME"), ".config")): configdir = os.path.join(os.getenv("HOME"), ".config", "epr") os.makedirs(configdir, exist_ok=True) if os.path.isfile(STATEFILE): if os.path.isfile(os.path.join(configdir, "config")): os.remove(os.path.join(configdir, "config")) shutil.move(STATEFILE, os.path.join(configdir, "config")) STATEFILE = os.path.join(configdir, "config") elif os.getenv("USERPROFILE") is not None: STATEFILE = os.path.join(os.getenv("USERPROFILE"), ".epr") else: STATEFILE = os.devnull if os.path.exists(STATEFILE): with open(STATEFILE, "r") as f: STATE = json.load(f)
Example #4
Source File: test_utils.py From dynamic-training-with-apache-mxnet-on-aws with Apache License 2.0 | 6 votes |
def discard_stderr(): """ Discards error output of a routine if invoked as: with discard_stderr(): ... """ with open(os.devnull, 'w') as bit_bucket: try: stderr_fileno = sys.stderr.fileno() old_stderr = os.dup(stderr_fileno) try: os.dup2(bit_bucket.fileno(), stderr_fileno) yield finally: os.dup2(old_stderr, stderr_fileno) except AttributeError: # On some systems is stderr not a file descriptor but actually a virtual pipeline # that can not be copied yield
Example #5
Source File: test_Observatory.py From EXOSIMS with BSD 3-Clause "New" or "Revised" License | 6 votes |
def setUp(self): self.dev_null = open(os.devnull, 'w') # self.spec = {"modules": {"PlanetPhysicalModel": "PlanetPhysicalModel"}} self.script = resource_path('test-scripts/template_minimal.json') with open(self.script) as f: self.spec = json.loads(f.read()) modtype = getattr(EXOSIMS.Prototypes.Observatory.Observatory, '_modtype') pkg = EXOSIMS.Observatory self.allmods = [get_module(modtype)] for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__, pkg.__name__ + '.'): if not is_pkg: mod = get_module(module_name.split('.')[-1], modtype) self.assertTrue(mod._modtype is modtype, '_modtype mismatch for %s' % mod.__name__) self.allmods.append(mod)
Example #6
Source File: persistence.py From multibootusb with GNU General Public License v2.0 | 6 votes |
def detect_missing_tools(distro): tools_dir = os.path.join('data', 'tools') if platform.system() == 'Windows': _7zip_exe = gen.resource_path( os.path.join(tools_dir, '7zip', '7z.exe')) e2fsck_exe = gen.resource_path(os.path.join(tools_dir, 'cygwin', 'e2fsck.exe')) resize2fs_exe = gen.resource_path(os.path.join(tools_dir, 'cygwin', 'resize2fs.exe')) else: _7zip_exe = '7z' e2fsck_exe = 'e2fsck' resize2fs_exe = 'resize2fs' if distro not in creator_dict or \ creator_dict[distro][0] is not create_persistence_using_resize2fs: return None try: with open(os.devnull) as devnull: for tool in [e2fsck_exe, resize2fs_exe]: p = subprocess.Popen([tool], stdout=devnull, stderr=devnull) p.communicate() except FileNotFoundError: # Windows return "'%s.exe' is not installed or not available for use." % tool except OSError: # Linux return "'%s' is not installed or not available for use." % tool return None
Example #7
Source File: chromecast-beam.py From pulseaudio-dlna with GNU General Public License v3.0 | 6 votes |
def do_GET(self): client_address = self.client_address[0] logger.info('Serving transcoded media file to {} ...'.format( client_address)) self.send_head() path = self.translate_path(self.path) command = VLCEncoderSettings.command(path) logger.info('Launching {}'.format(command)) try: with open(os.devnull, 'w') as dev_null: encoder_process = subprocess.Popen( command, stdout=subprocess.PIPE, stderr=dev_null) shutil.copyfileobj(encoder_process.stdout, self.wfile) except: logger.info('Connection from {} closed.'.format(client_address)) logger.debug(traceback.format_exc()) finally: pid = encoder_process.pid logger.info('Terminating process {}'.format(pid)) try: os.kill(pid, signal.SIGKILL) except: pass
Example #8
Source File: osdriver.py From multibootusb with GNU General Public License v2.0 | 6 votes |
def gpt_device(self, dev_name): disk_dev = self.physical_disk(dev_name) cmd = ['parted', disk_dev, '-s', 'print'] with open(os.devnull) as devnull: p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=devnull) _cmd_out, _err_out = p.communicate() p.wait() if p.returncode != 0: lang = os.getenv('LANG') encoding = lang.rsplit('.')[-1] if lang else 'utf-8' raise RuntimeError(str(_err_out, encoding)) subprocess.check_call(['partprobe', disk_dev]) if b'msdos' in _cmd_out: return False if b'gpt' in _cmd_out: return True raise RuntimeError("Disk '%s' is uninitialized and not usable." % disk_dev)
Example #9
Source File: test_Completeness.py From EXOSIMS with BSD 3-Clause "New" or "Revised" License | 6 votes |
def setUp(self): self.dev_null = open(os.devnull, 'w') self.script = resource_path('test-scripts/template_minimal.json') with open(self.script) as f: self.spec = json.loads(f.read()) with RedirectStreams(stdout=self.dev_null): self.TL = TargetList(ntargs=10,**copy.deepcopy(self.spec)) self.TL.dist = np.random.uniform(low=0,high=100,size=self.TL.nStars)*u.pc modtype = getattr(Completeness,'_modtype') pkg = EXOSIMS.Completeness self.allmods = [get_module(modtype)] for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__, pkg.__name__+'.'): if (not 'starkAYO' in module_name) and not is_pkg: mod = get_module(module_name.split('.')[-1],modtype) self.assertTrue(mod._modtype is modtype,'_modtype mismatch for %s'%mod.__name__) self.allmods.append(mod)
Example #10
Source File: test_PostProcessing.py From EXOSIMS with BSD 3-Clause "New" or "Revised" License | 6 votes |
def setUp(self): self.dev_null = open(os.devnull, 'w') self.specs = {'modules':{'BackgroundSources':' '}} script = resource_path('test-scripts/template_minimal.json') with open(script) as f: spec = json.loads(f.read()) with RedirectStreams(stdout=self.dev_null): self.TL = TargetList(**spec) modtype = getattr(EXOSIMS.Prototypes.PostProcessing.PostProcessing,'_modtype') pkg = EXOSIMS.PostProcessing self.allmods = [get_module(modtype)] for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__, pkg.__name__+'.'): if not is_pkg: mod = get_module(module_name.split('.')[-1],modtype) self.assertTrue(mod._modtype is modtype,'_modtype mismatch for %s'%mod.__name__) self.allmods.append(mod) #Testing some limiting cases below
Example #11
Source File: test_ZodiacalLight.py From EXOSIMS with BSD 3-Clause "New" or "Revised" License | 6 votes |
def setUp(self): self.dev_null = open(os.devnull, 'w') self.script = resource_path('test-scripts/template_prototype_testing.json') with open(self.script) as f: self.spec = json.loads(f.read()) with RedirectStreams(stdout=self.dev_null): self.sim = MissionSim.MissionSim(self.script) self.TL = self.sim.TargetList self.nStars = self.TL.nStars self.star_index = np.array(range(0, self.nStars)) self.Obs = self.sim.Observatory self.mode = self.sim.OpticalSystem.observingModes[0] self.TK = self.sim.TimeKeeping assert self.nStars > 10, "Need at least 10 stars in the target list for the unit test." self.unit = 1./u.arcsec**2 modtype = getattr(EXOSIMS.Prototypes.ZodiacalLight.ZodiacalLight, '_modtype') pkg = EXOSIMS.ZodiacalLight self.allmods = [get_module(modtype)] for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__, pkg.__name__ + '.'): if not is_pkg: mod = get_module(module_name.split('.')[-1], modtype) self.assertTrue(mod._modtype is modtype, '_modtype mismatch for %s' % mod.__name__) self.allmods.append(mod)
Example #12
Source File: notify.py From Quiver-alfred with MIT License | 6 votes |
def convert_image(inpath, outpath, size): """Convert an image file using `sips`. Args: inpath (str): Path of source file. outpath (str): Path to destination file. size (int): Width and height of destination image in pixels. Raises: RuntimeError: Raised if `sips` exits with non-zero status. """ cmd = [ b'sips', b'-z', b'{0}'.format(size), b'{0}'.format(size), inpath, b'--out', outpath] # log().debug(cmd) with open(os.devnull, 'w') as pipe: retcode = subprocess.call(cmd, stdout=pipe, stderr=subprocess.STDOUT) if retcode != 0: raise RuntimeError('sips exited with {0}'.format(retcode))
Example #13
Source File: test_SimulatedUniverse.py From EXOSIMS with BSD 3-Clause "New" or "Revised" License | 6 votes |
def setUp(self): self.dev_null = open(os.devnull, 'w') self.script = resource_path('test-scripts/template_minimal.json') with open(self.script) as f: self.spec = json.loads(f.read()) with RedirectStreams(stdout=self.dev_null): self.TL = TargetList(ntargs=10,**copy.deepcopy(self.spec)) self.TL.dist = np.random.uniform(low=0,high=100,size=self.TL.nStars)*u.pc modtype = getattr(SimulatedUniverse,'_modtype') pkg = EXOSIMS.SimulatedUniverse self.allmods = [get_module(modtype)] for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__, pkg.__name__+'.'): if not is_pkg: mod = get_module(module_name.split('.')[-1],modtype) self.assertTrue(mod._modtype is modtype,'_modtype mismatch for %s'%mod.__name__) self.allmods.append(mod)
Example #14
Source File: test_OpticalSystem.py From EXOSIMS with BSD 3-Clause "New" or "Revised" License | 6 votes |
def setUp(self): self.dev_null = open(os.devnull, 'w') self.script = resource_path('test-scripts/template_minimal.json') with open(self.script) as f: self.spec = json.loads(f.read()) with RedirectStreams(stdout=self.dev_null): self.TL = TargetList(ntargs=10,**copy.deepcopy(self.spec)) modtype = getattr(OpticalSystem,'_modtype') pkg = EXOSIMS.OpticalSystem self.allmods = [get_module(modtype)] for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__, pkg.__name__+'.'): if not is_pkg: mod = get_module(module_name.split('.')[-1],modtype) self.assertTrue(mod._modtype is modtype,'_modtype mismatch for %s'%mod.__name__) self.allmods.append(mod)
Example #15
Source File: fonts-subset-support.py From gftools with Apache License 2.0 | 6 votes |
def main(argv): if len(argv) != 2 or not os.path.isdir(argv[1]): sys.exit('Must have one argument, a directory containing font files.') sys.stderr = open(os.devnull, 'w') dirpath = argv[1] result = True files = [] for font in fonts.Metadata(dirpath).fonts: files.append(os.path.join(dirpath, font.filename)) for subset in fonts.Metadata(dirpath).subsets: if subset == 'menu': continue (file1, file2, diff_size) = _LeastSimilarCoverage(files, subset) if diff_size > FLAGS.max_diff_cps: print('%s coverage for %s failed' % (dirpath, subset)) print('Difference of codepoints between %s & %s is %d' % ( file1, file2, diff_size)) result = False if result: print('%s passed subset coverage' % (dirpath))
Example #16
Source File: test_BackgroundSources.py From EXOSIMS with BSD 3-Clause "New" or "Revised" License | 6 votes |
def setUp(self): self.dev_null = open(os.devnull, 'w') modtype = getattr(EXOSIMS.Prototypes.BackgroundSources.BackgroundSources,'_modtype') pkg = EXOSIMS.BackgroundSources self.allmods = [get_module(modtype)] for loader, module_name, is_pkg in pkgutil.walk_packages(pkg.__path__, pkg.__name__+'.'): if not is_pkg: mod = get_module(module_name.split('.')[-1],modtype) self.assertTrue(mod._modtype is modtype,'_modtype mismatch for %s'%mod.__name__) self.allmods.append(mod) # need a TargetList object for testing script = resource_path('test-scripts/template_prototype_testing.json') with open(script) as f: spec = json.loads(f.read()) with RedirectStreams(stdout=self.dev_null): self.TL = TargetList(**spec)
Example #17
Source File: migration_linter.py From django-migration-linter with Apache License 2.0 | 6 votes |
def get_sql(self, app_label, migration_name): logger.info( "Calling sqlmigrate command {} {}".format(app_label, migration_name) ) dev_null = open(os.devnull, "w") try: sql_statement = call_command( "sqlmigrate", app_label, migration_name, database=self.database, stdout=dev_null, ) except (ValueError, ProgrammingError): logger.warning( ( "Error while executing sqlmigrate on (%s, %s). " "Continuing execution with empty SQL." ), app_label, migration_name, ) sql_statement = "" return sql_statement.splitlines()
Example #18
Source File: iosys_test.py From python-control with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_iosys_print(self): # Send the output to /dev/null import os f = open(os.devnull,"w") # Simple I/O system iosys = ct.ss2io(self.siso_linsys) print(iosys, file=f) # I/O system without ninputs, noutputs ios_unspecified = ios.NonlinearIOSystem(secord_update, secord_output) print(ios_unspecified, file=f) # I/O system with derived inputs and outputs ios_linearized = ios.linearize(ios_unspecified, [0, 0], [0]) print(ios_linearized, file=f) f.close()
Example #19
Source File: manager.py From gym-pull with MIT License | 6 votes |
def _list_packages(self): packages = {} # package_name before first (, package version before space, comma, or ending parenthese # e.g. functools32 (3.2.3.post2) or gym (0.1.6, /www/ppaquette/gym) => name: functools32, version=>3.2.3.post2 package_re = re.compile(r'^([^\(]+) \(([^ ,\)]*)') temp_file = os.path.join(tempfile.mkdtemp(), 'pip_list.txt') self._run_cmd('{} list --format=legacy --log {} > {}'.format(pip_exec, temp_file, os.devnull)) with open(temp_file) as f: for line in f: match = package_re.search(line) if match is not None: packages[match.group(1).strip()] = match.group(2) shutil.rmtree(os.path.dirname(temp_file)) return packages
Example #20
Source File: omxplayer.py From pi_video_looper with GNU General Public License v2.0 | 6 votes |
def play(self, movie, loop=None, vol=0): """Play the provided movie file, optionally looping it repeatedly.""" self.stop(3) # Up to 3 second delay to let the old player stop. # Assemble list of arguments. args = ['omxplayer'] args.extend(['-o', self._sound]) # Add sound arguments. args.extend(self._extra_args) # Add extra arguments from config. if vol is not 0: args.extend(['--vol', str(vol)]) if loop is None: loop = movie.repeats if loop <= -1: args.append('--loop') # Add loop parameter if necessary. if self._show_titles and movie.title: srt_path = os.path.join(self._get_temp_directory(), 'video_looper.srt') with open(srt_path, 'w') as f: f.write(self._subtitle_header) f.write(movie.title) args.extend(['--subtitles', srt_path]) args.append(movie.filename) # Add movie file path. # Run omxplayer process and direct standard output to /dev/null. self._process = subprocess.Popen(args, stdout=open(os.devnull, 'wb'), close_fds=True)
Example #21
Source File: docker.py From pywren-ibm-cloud with Apache License 2.0 | 6 votes |
def delete_runtime(self, docker_image_name, memory): """ Deletes a runtime """ if docker_image_name == 'default': docker_image_name = self._get_default_runtime_image_name() logger.debug('Deleting {} runtime'.format(docker_image_name)) name = self._format_runtime_name(docker_image_name) if self._is_localhost: if self.docker_client: self.docker_client.containers.stop(name, force=True) else: cmd = 'docker rm -f {}'.format(name) if not self.log_level: cmd = cmd + " >{} 2>&1".format(os.devnull) os.system(cmd) else: cmd = 'docker rm -f {}'.format(name) self._ssh_run_remote_command(cmd)
Example #22
Source File: docker.py From pywren-ibm-cloud with Apache License 2.0 | 6 votes |
def delete_all_runtimes(self): """ Delete all created runtimes """ if self._is_localhost: if self.docker_client: running_containers = self.docker_client.containers.list(filters={'name': 'pywren'}) for runtime in running_containers: logger.debug('Deleting {} runtime'.format(runtime.name)) runtime.stop() else: list_runtimes_cmd = "docker ps -a -f name=pywren | awk '{print $NF}' | tail -n +2" running_containers = subprocess.check_output(list_runtimes_cmd, shell=True).decode().strip() for name in running_containers.splitlines(): cmd = 'docker rm -f {}'.format(name) if not self.log_level: cmd = cmd + " >{} 2>&1".format(os.devnull) os.system(cmd) else: list_runtimes_cmd = "docker ps -a -f name=pywren | awk '{print $NF}' | tail -n +2" running_containers = self._ssh_run_remote_command(list_runtimes_cmd) for name in running_containers.splitlines(): cmd = 'docker rm -f {}'.format(name) self._ssh_run_remote_command(cmd)
Example #23
Source File: knative.py From pywren-ibm-cloud with Apache License 2.0 | 6 votes |
def _build_default_runtime(self, default_runtime_img_name): """ Builds the default runtime """ if os.system('docker --version >{} 2>&1'.format(os.devnull)) == 0: # Build default runtime using local dokcer python_version = version_str(sys.version_info).replace('.', '') location = 'https://raw.githubusercontent.com/pywren/pywren-ibm-cloud/master/runtime/knative' resp = requests.get('{}/Dockerfile.python{}'.format(location, python_version)) dockerfile = "Dockefile.default-kantive-runtime" if resp.status_code == 200: with open(dockerfile, 'w') as f: f.write(resp.text) self.build_runtime(default_runtime_img_name, dockerfile) os.remove(dockerfile) else: msg = 'There was an error fetching the default runitme Dockerfile: {}'.format(resp.text) logger.error(msg) exit() else: # Build default runtime using Tekton self._build_default_runtime_from_git(default_runtime_img_name)
Example #24
Source File: hello_video.py From pi_video_looper with GNU General Public License v2.0 | 6 votes |
def play(self, movie, loop=None, **kwargs): """Play the provided movied file, optionally looping it repeatedly.""" self.stop(3) # Up to 3 second delay to let the old player stop. # Assemble list of arguments. args = ['hello_video.bin'] if loop is None: loop = movie.repeats if loop <= -1: args.append('--loop') # Add loop parameter if necessary. elif loop > 0: args.append('--loop={0}'.format(loop)) #loop=0 means no loop args.append(movie.filename) # Add movie file path. # Run hello_video process and direct standard output to /dev/null. self._process = subprocess.Popen(args, stdout=open(os.devnull, 'wb'), close_fds=True)
Example #25
Source File: notify.py From gist-alfred with MIT License | 6 votes |
def convert_image(inpath, outpath, size): """Convert an image file using ``sips``. Args: inpath (str): Path of source file. outpath (str): Path to destination file. size (int): Width and height of destination image in pixels. Raises: RuntimeError: Raised if ``sips`` exits with non-zero status. """ cmd = [ b'sips', b'-z', str(size), str(size), inpath, b'--out', outpath] # log().debug(cmd) with open(os.devnull, 'w') as pipe: retcode = subprocess.call(cmd, stdout=pipe, stderr=subprocess.STDOUT) if retcode != 0: raise RuntimeError('sips exited with %d' % retcode)
Example #26
Source File: test_z_cmdline.py From tox with MIT License | 6 votes |
def _alwayscopy_not_supported(): # This is due to virtualenv bugs with alwayscopy in some platforms # see: https://github.com/pypa/virtualenv/issues/565 supported = True tmpdir = tempfile.mkdtemp() try: with open(os.devnull) as fp: subprocess.check_call( [sys.executable, "-m", "virtualenv", "--always-copy", tmpdir], stdout=fp, stderr=fp, ) except subprocess.CalledProcessError: supported = False finally: shutil.rmtree(tmpdir) return not supported
Example #27
Source File: git.py From openSUSE-release-tools with GNU General Public License v2.0 | 5 votes |
def sync(cache_dir, repo_url, message=None): cwd = os.getcwd() devnull = open(os.devnull, 'wb') # Ensure git-sync tool is available. git_sync_dir = path.join(cache_dir, 'git-sync') git_sync_exec = path.join(git_sync_dir, 'git-sync') if not path.exists(git_sync_dir): os.makedirs(git_sync_dir) clone('https://github.com/simonthum/git-sync.git', git_sync_dir) else: os.chdir(git_sync_dir) subprocess.call(['git', 'pull', 'origin', 'master'], stdout=devnull, stderr=devnull) repo_name = path.basename(path.normpath(repo_url)) repo_dir = path.join(cache_dir, repo_name) if not path.exists(repo_dir): os.makedirs(repo_dir) clone(repo_url, repo_dir) os.chdir(repo_dir) subprocess.call(['git', 'config', '--bool', 'branch.master.sync', 'true']) subprocess.call(['git', 'config', '--bool', 'branch.master.syncNewFiles', 'true']) if message: subprocess.call(['git', 'config', 'branch.master.syncCommitMsg', message]) os.chdir(repo_dir) return_code = subprocess.call([git_sync_exec]) if return_code != 0: raise Exception('failed to sync {}'.format(repo_name)) os.chdir(cwd) return repo_dir
Example #28
Source File: prepro_feats.py From video-caption-openNMT.pytorch with MIT License | 5 votes |
def extract_frames(video, dst): with open(os.devnull, "w") as ffmpeg_log: if os.path.exists(dst): print(" cleanup: " + dst + "/") shutil.rmtree(dst) os.makedirs(dst) video_to_frames_command = ["ffmpeg", # (optional) overwrite output file if it exists '-y', '-i', video, # input file '-vf', "scale=400:300", # input file '-qscale:v', "2", # quality for JPEG '{0}/%06d.jpg'.format(dst)] subprocess.call(video_to_frames_command, stdout=ffmpeg_log, stderr=ffmpeg_log)
Example #29
Source File: git.py From openSUSE-release-tools with GNU General Public License v2.0 | 5 votes |
def sync(cache_dir, repo_url, message=None): cwd = os.getcwd() devnull = open(os.devnull, 'wb') # Ensure git-sync tool is available. git_sync_dir = path.join(cache_dir, 'git-sync') git_sync_exec = path.join(git_sync_dir, 'git-sync') if not path.exists(git_sync_dir): os.makedirs(git_sync_dir) clone('https://github.com/simonthum/git-sync.git', git_sync_dir) else: os.chdir(git_sync_dir) subprocess.call(['git', 'pull', 'origin', 'master'], stdout=devnull, stderr=devnull) repo_name = path.basename(path.normpath(repo_url)) repo_dir = path.join(cache_dir, repo_name) if not path.exists(repo_dir): os.makedirs(repo_dir) clone(repo_url, repo_dir) os.chdir(repo_dir) subprocess.call(['git', 'config', '--bool', 'branch.master.sync', 'true']) subprocess.call(['git', 'config', '--bool', 'branch.master.syncNewFiles', 'true']) if message: subprocess.call(['git', 'config', 'branch.master.syncCommitMsg', message]) os.chdir(repo_dir) return_code = subprocess.call([git_sync_exec]) if return_code != 0: raise Exception('failed to sync {}'.format(repo_name)) os.chdir(cwd) return repo_dir
Example #30
Source File: core_library.py From toonapilib with MIT License | 5 votes |
def is_venv_created(): warnings.simplefilter("ignore", ResourceWarning) dev_null = open(os.devnull, 'w') venv = Popen(['pipenv', '--venv'], stdout=PIPE, stderr=dev_null).stdout.read().strip() return True if venv else False