def binary_dependencies(self): namespace = PropertyNamespace('bins', _(u'Binary dependencies')) tesseract = pbs.Command(TESSERACT_PATH) try: namespace.add_property('tesseract', _(u'tesseract version'), tesseract('-v').stderr, report=True) except pbs.CommandNotFound: namespace.add_property('tesseract', _(u'tesseract version'), _(u'not found'), report=True) except Exception: namespace.add_property('tesseract', _(u'tesseract version'), _(u'error getting version'), report=True) unpaper = pbs.Command(UNPAPER_PATH) try: namespace.add_property('unpaper', _(u'unpaper version'), unpaper('-V').stdout, report=True) except pbs.CommandNotFound: namespace.add_property('unpaper', _(u'unpaper version'), _(u'not found'), report=True) except Exception: namespace.add_property('unpaper', _(u'unpaper version'), _(u'error getting version'), report=True) pdftotext = pbs.Command(PDFTOTEXT_PATH) try: namespace.add_property('pdftotext', _(u'pdftotext version'), pdftotext('-v').stderr, report=True) except pbs.CommandNotFound: namespace.add_property('pdftotext', _(u'pdftotext version'), _(u'not found'), report=True) except Exception: namespace.add_property('pdftotext', _(u'pdftotext version'), _(u'error getting version'), report=True)
def do_check(): pbs.Command("hg")("id", "-i", "c:\\xampp\\htdocs\\web", _out="output.txt") text = open("output.txt", "r").read() regex_result = re.compile("(?P<node>\w+)\+*").search(text) local_revision = regex_result.groupdict()['node'] r = requests.get( 'https://bitbucket.org/api/1.0/repositories/andrewking/web/changesets/?limit=1', auth=('myusername', 'mypassword')) if r.status_code == 200: result = r.json() if result['changesets'][0]['node'] != local_revision: print "Found new revision", result['changesets'][0][ 'node'], "- Doing test runs..." pbs.Command('powershell.exe')( 'c:\\xampp\\htdocs\\web\\testing\\run.ps1') print "Done tests" return True return False
def Command(attr): """Return command object like sh.""" for key in os.environ: if six.PY2 and not isinstance(os.environ[key], str): print('Converting {} = {}({})'.format( key, type(os.environ[key]), os.environ[key])) os.environ[key] = str( unicodedata.normalize('NFKD', os.environ[key]).encode( 'ascii', 'ignore')) print('Converting {} = {}({})'.format( key, type(os.environ[key]), os.environ[key])) return pbs.Command(attr)
def __getattr__(self, attr): if hasattr(pbs, attr): return getattr(pbs, attr) return pbs.Command(attr)
def Command(attr): """Return command object like sh.""" return pbs.Command(attr)
def __getattr__(self, attr): """Return command object like sh.""" return pbs.Command(attr)
def __getattr__(self, attr): return pbs.Command(attr)
# This file is part of INGInious. See the LICENSE and the COPYRIGHTS files for # more information about the licensing of this file. """ A plugin that allows to save submissions to a Git repository """ import queue import io import sys import logging import os.path import shutil import tarfile import threading import inginious.common.custom_yaml if sys.platform == 'win32': import pbs git = pbs.Command('git') else: from sh import git # pylint: disable=no-name-in-module class SubmissionGitSaver(threading.Thread): """ Thread class that saves results from submission in the git repo. It must be a thread as a git commit can take some time and because we extract archives returned by the Client. But it must also be launched only one time as our git operations are not really process/tread-safe ;-) """ def __init__(self, plugin_manager, config): threading.Thread.__init__(self) self._logger = logging.getLogger( "inginious.webapp.plugins.SubmissionGitSaver")
import pbs import http.client as http from urllib.parse import urlparse import json import uuid import re import os import hashlib git = pbs.Command("git") def get_branch(): binfo = git("branch") m = re.search("\*[ ]*([^ \r\n]*)", binfo.stdout, 0) if m: return m.group(1) else: return "master" def get_head_rev(): head_rev = git("rev-parse", "HEAD") return head_rev.stdout[:10] def get_version_load(branch): build_info_url = "http://buildserver.urbackup.org/urbackup_build_version_" + branch + ".json" print("Build info url: " + build_info_url) target = urlparse(build_info_url) method = 'GET'
import urllib import zipfile from abc import ABCMeta, abstractmethod from contextlib import contextmanager from distutils import file_util, dir_util from utils import IS_MAC, IS_WIN if IS_MAC: from sh import SetFile, hdiutil, codesign from darwin_dyliber import fix_all_dylibs if IS_WIN: import pbs from pbs import cd, glob git = pbs.Command("C:\\Program Files\\Git\\bin\\git.exe") python = pbs.Command("C:\\Python27\\python.exe") mkdir = pbs.Command("C:\\Program Files\\Git\\bin\\mkdir.exe") make = pbs.Command("C:\\MinGW\\bin\\mingw32-make.exe") cp = pbs.Command("C:\\Program Files\\Git\\bin\\cp.exe") rm = pbs.Command("C:\\Program Files\\Git\\bin\\rm.exe") find = pbs.Command("C:\\Program Files\\Git\\bin\\find.exe") ln = pbs.Command("C:\\Program Files\\Git\\bin\\ln.exe") tar = pbs.Command("C:\\Program Files\\Git\\bin\\tar.exe") mv = pbs.Command("C:\\Program Files\\Git\\bin\\mv.exe") else: from sh import git, cd, python, mkdir, make, cp, glob, rm from sh import find, ln, tar, mv, strip from depcollector import collect_deps
#!/usr/bin/env python #-*- coding:utf-8 -*- import pytest import os from os import path, listdir if os.name == 'nt': import pbs apng2webp = pbs.Command('apng2webp') else: from sh import apng2webp # test apng2webp cli def test_main(): apng_dir = path.realpath(path.join(__file__, '../../../examples/apng')) webp_dir = path.realpath(path.join(__file__, '../../../examples/webp')) assert (path.isdir(apng_dir)) assert (path.isdir(webp_dir)) for f in listdir(apng_dir): f_name, f_ext = path.splitext(f) if f_ext == '.png': input_path = path.realpath(path.join(apng_dir, f_name + '.png')) output_path = path.realpath(path.join(webp_dir, f_name + '.webp')) apng2webp(input_path, output_path) assert (os.path.exists(output_path))
#!/usr/bin/env python #-*- coding:utf-8 -*- import sys import os from os import path import json import errno from tempfile import mkdtemp import shutil import argparse if os.name == 'nt': import pbs apng2webp_apngopt = pbs.Command('apng2webp_apngopt') apngdisraw = pbs.Command('apngdisraw') cwebp = pbs.Command('cwebp') webpmux = pbs.Command('webpmux') else: from sh import apng2webp_apngopt, apngdisraw, cwebp, webpmux def apng2webp(input_file, output_file, tmpdir, loop, bgcolor): de_optimised_file = path.join(tmpdir, "de-optimised.png") animation_json_file = path.join(tmpdir, "animation_metadata.json") # apng2webp_apngopt does only optimization which can be applied to webp. # apng2webp_apngopt does not return a error code if things go wrong at time of writing. (like can't write/read file) apng2webp_apngopt(input_file, de_optimised_file)
import os import optparse import pbs APP_LIST = ('acls', 'checkouts', 'common', 'converter', 'django_gpg', 'documents', 'document_comments', 'document_indexing', 'document_signatures', 'dynamic_search', 'folders', 'history', 'installation', 'linking', 'main', 'metadata', 'navigation', 'ocr', 'permissions', 'project_setup', 'project_tools', 'scheduler', 'smart_settings', 'sources', 'tags', 'user_management', 'web_theme', 'bootstrap', 'registration') LANGUAGE_LIST = ('ar', 'bg', 'de_DE', 'en', 'es', 'fr', 'it', 'nl_NL', 'pl', 'pt', 'pt_BR', 'ru', 'sr_RS') makemessages = pbs.Command('django-admin.py') makemessages = makemessages.bake('makemessages') compilemessages = pbs.Command('django-admin.py') compilemessages = compilemessages.bake('compilemessages') if hasattr(sys, 'real_prefix'): # We are inside a virtual env BASE_DIR = os.path.join(os.environ['VIRTUAL_ENV'], '..') else: BASE_DIR = os.getcwd() def process(command, app_list, language_list): if command == makemessages: print 'Making messages'
''' Pergunta e calcula estatisticas de idade dos lista_entrevistado Este código é dividido em quatro partes a seguir: 1º parte: Ler o arquivo Json 2º parte: fazendo novas perguntas 3º parte: salvando tudo no arquivo 4º parte: calculando e mostrando estatisticas ''' import meuprograma import statistics import json import pbs convert = pbs.Command('sh') def carrega_dados(): ''' Carrega as informações do arquivo Json Popula a lista lista_entrevistado com instancia da classe Entrevista com os valores que vem do arquivo Json ''' global lista_entrevistado def pega_dados(obj): ''' Cria uma instancia nova de Entrevista.