Python version.version() Examples

The following are 30 code examples of version.version(). 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 version , or try the search function .
Example #1
Source File: svgcanvas.py    From lpts with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, fname):
        basecanvas.T.__init__(self)
        self.__out_fname = fname
        self.__xmin, self.__xmax, self.__ymin, self.__ymax = 0,0,0,0
        self.__doc = Document()
        self.__doc.appendChild(self.__doc.createComment
             ('Created by PyChart ' + version.version + ' ' + version.copyright))
        self.__svg = self.__doc.createElement('svg') # the svg doc
        self.__doc.appendChild(self.__svg)
        self.__defs = self.__doc.createElement('defs') # for clip paths
        self.__svg.appendChild(self.__defs)
        self.__cur_element = self.__svg
        self.gsave()       # create top-level group for dflt styles
        self.__update_style(font_family = theme.default_font_family,
                            font_size = theme.default_font_size,
                            font_style = 'normal',
                            font_weight = 'normal',
                            font_stretch = 'normal',
                            fill = 'none',
                            stroke = 'rgb(0,0,0)', #SVG dflt none, PS dflt blk
                            stroke_width = theme.default_line_width,
                            stroke_linejoin = 'miter',
                            stroke_linecap = 'butt',
                            stroke_dasharray = 'none') 
Example #2
Source File: basecanvas.py    From lpts with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self):
        global active_canvases

        self.__xmax = -InvalidCoord
        self.__xmin = InvalidCoord
        self.__ymax = -InvalidCoord
        self.__ymin = InvalidCoord
        self.__clip_box = (-InvalidCoord, -InvalidCoord, InvalidCoord, InvalidCoord)
        self.__clip_stack = []
        self.__nr_gsave = 0

        self.title = theme.title or re.sub("(.*)\\.py$", "\\1", sys.argv[0])
        self.creator = theme.creator or "pychart %s" % (version.version,)
        self.creation_date = theme.creation_date or \
                             time.strftime("(%m/%d/%y) (%I:%M %p)")
        self.author = theme.author
        self.aux_comments = theme.aux_comments or ""
        active_canvases.append(self) 
Example #3
Source File: text.py    From OpenRAM with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def baselevels(self, s, maxlevel=1, brackets="()"):
        """strip parts of a string above a given bracket level
        - return a modified (some parts might be removed) version of the string s
          where all parts inside brackets with level higher than maxlevel are
          removed
        - if brackets do not match (number of left and right brackets is wrong
          or at some points there were more right brackets than left brackets)
          just return the unmodified string"""
        level = 0
        highestlevel = 0
        res = ""
        for c in s:
            if c == brackets[0]:
                level += 1
                if level > highestlevel:
                    highestlevel = level
            if level <= maxlevel:
                res += c
            if c == brackets[1]:
                level -= 1
        if level == 0 and highestlevel > 0:
            return res 
Example #4
Source File: update.py    From PCWG with MIT License 6 votes vote down vote up
def download_version(self, version):
        
        try:    
            
            Status.add("Downloading latest version")
            
            zip_file = "pcwg_tool-{0}.zip".format(version.version)
            url = "https://github.com/peterdougstuart/PCWG/releases/download/{0}/{1}".format(version.tag, zip_file)
            Status.add(url)
            
            urllib.urlretrieve (url, Updator.update_zip)
                
            Status.add("Download complete")
            
        except Exception as e:
    
            Status.add("Cannot download latest version: {0}".format(e)) 
Example #5
Source File: update.py    From PCWG with MIT License 6 votes vote down vote up
def get_lastest_version(self):
        
        try:
            
            r  = requests.get("https://github.com/peterdougstuart/PCWG/releases/latest")
            #note the above will forward to a URL like: https://github.com/peterdougstuart/PCWG/releases/tag/v0.5.13
                    
            data = r.url.split("/")   
            
            return Version(data[-1])
            
        except Exception as e:
    
            Status.add("Cannot determine latest version: {0}".format(e))

            return Version(None) 
Example #6
Source File: service.py    From opensnitch with GNU General Public License v3.0 6 votes vote down vote up
def Ping(self, request, context):
        if self._is_local_request(context):
            self._last_ping = datetime.now()
            self._stats_dialog.update(request.stats)

            if request.stats.daemon_version != version:
                self._version_warning_trigger.emit(request.stats.daemon_version, version)
        else:
            with self._remote_lock:
                _, addr, _ = context.peer().split(':')
                if addr in self._remote_stats:
                    self._remote_stats[addr].update(request.stats)
                else:
                    self._new_remote_trigger.emit(addr, request.stats)

        return ui_pb2.PingReply(id=request.id) 
Example #7
Source File: reporting.py    From PCWG with MIT License 6 votes vote down vote up
def report(self, path, analysis, powerDeviationMatrix = True, scatterMetric=True):
        
        self.analysis = analysis
        book = xlwt.Workbook()


        sh = book.add_sheet("Anonymous Report", cell_overwrite_ok=True)
        sh.write(0, 0, "PCWG Tool Version Number:")
        sh.write(0, 1, self.version)
        sh.write(0, 2, xlwt.Formula('HYPERLINK("http://www.pcwg.org";"PCWG Website")'))
        row = 1

        if powerDeviationMatrix:
            row = self.report_power_deviation_matrix(sh,analysis,book)

        if scatterMetric:
            row = self.report_scatter_metric(sh,analysis,row, analysis.turbRenormActive)

        book.save(path) 
Example #8
Source File: createBundle.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def readVersion():
    version=None
    try:
      f=open('__version.py')
      verSrc=f.read()
      f.close()
      exec verSrc
    except:
      pass
    return version 
Example #9
Source File: root.py    From PCWG with MIT License 5 votes vote down vote up
def About(self):

        tkMessageBox.showinfo("PCWG-Tool About", "Version: {vers} \nVisit http://www.pcwg.org for more info".format(vers=ver.version)) 
Example #10
Source File: preferences_configuration.py    From PCWG with MIT License 5 votes vote down vote up
def __init__(self, version):

        self.path = "preferences.xml"
        self.versionLastOpened = version
        self.recents = []
        self.onRecentChange = EventHook()

        try:
            loaded = self.loadPreferences()
        except Exception as e:
            Status.add(str(e))
            loaded = False

        if not loaded:

            self.analysisLastOpened =  ""
            self.datasetLastOpened = ""
            self.portfolioLastOpened = ""
            self.powerCurveLastOpened = ""
            self.benchmarkLastOpened = ""
            self.verbosity = 1
            self.debug = False
            self.isNew = True

        else:

            self.isNew = False 
Example #11
Source File: preferences_configuration.py    From PCWG with MIT License 5 votes vote down vote up
def get(cls):

        if cls.Instance == None:
            cls.Instance = Preferences(ver.version)

        return cls.Instance 
Example #12
Source File: update.py    From PCWG with MIT License 5 votes vote down vote up
def start_extractor(self):
        
        if not self.version_downloaded:
            raise Exception("No version downloaded")
            
        if not os.path.isfile(Updator.extractor_path):
            raise Exception("{0} not found".format(Updator.extractor_path))
            
        Status.add("Starting extractor")

        subprocess.Popen([Updator.extractor_path]) 
Example #13
Source File: update.py    From PCWG with MIT License 5 votes vote down vote up
def __init__(self, tag):
        
        if tag != None:

            self.tag = tag.lower()
            self.version = re.findall("\d+\.?\d+\.?\d+", self.tag)[0].lower()
            
            data = self.version.split(".")
            
            self.major = data[0]
            
            if len(data) > 1:
                self.minor = data[1]
            else:
                self.minor = None
                
            if len(data) > 2:
                self.revision = data[2]
            else:
                self.revision = None

        else:

            self.tag = None
            self.version = None
            self.major = None
            self.minor = None
            self.revision = None 
Example #14
Source File: share.py    From PCWG with MIT License 5 votes vote down vote up
def pcwg_data_share_report(self, output_file_name):
                
        rpt = PCWGShareXReport(self.analysis,
                               version=ver.version,
                               output_fname=output_file_name,
                               pcwg_inner_ranges=ShareAnalysisBase.pcwg_inner_ranges,
                               share_name=self.share_factory.share_name)

        rpt.report()
        return rpt 
Example #15
Source File: reporting.py    From PCWG with MIT License 5 votes vote down vote up
def __init__(self,targetPowerCurve,wind_bins, turbulence_bins, version="unknown"):

        self.version = version
        self.targetPowerCurve = targetPowerCurve
        self.turbulenceBins = turbulence_bins
        self.normalisedWindSpeedBins = wind_bins 
Example #16
Source File: reporting.py    From PCWG with MIT License 5 votes vote down vote up
def __init__(self, windSpeedBins, calculated_power_deviation_matrix_dimensions):
        
        self.version = ver.version
        
        self.windSpeedBins = windSpeedBins
        self.calculated_power_deviation_matrix_dimensions = calculated_power_deviation_matrix_dimensions 
Example #17
Source File: Update.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def __init__(self):
    self.info=None
    self.message=None
    self.exception=None
    
    if not Crypto:
      self.message=xlt("No Crypto lib available.")
      return
    modsUsed={}
    for server in adm.config.getServers():
      mod=server.split('/')[0]
      modsUsed[mod] = modsUsed.get(mod, 0) +1
      
    try:
      info = "?ver=%s&rev=%s&mods=%s" % (admVersion.version, admVersion.revDate.replace(' ', '_'), ",".join(modsUsed.keys()))
      response=HttpGet("https://www.admin4.org/update.xml%s" % info)
      xmlText=response.text
      sigres=HttpGet("https://www.admin4.org/update.sign")
      signature=sigres.content
      
    except Exception as ex:
      self.exception = ex
      self.message=xlt("Online update check failed.\n\nError reported:\n  %s") % str(ex)
      return

    if True: # we want to check the signature
      f=open(os.path.join(adm.loaddir, 'admin4.pubkey'))
      keyBytes=f.read()
      f.close()

      # https://www.dlitz.net/software/pycrypto/api/current/Crypto-module.html
      pubkey=Crypto.PublicKey.RSA.importKey(keyBytes)
      verifier = Crypto.Signature.PKCS1_v1_5.new(pubkey)
      hash=Crypto.Hash.SHA.new(xmlText)

      if not verifier.verify(hash, signature):
        self.message = xlt("Online update check failed:\nupdate.xml cryptographic signature not valid.")
        return
    
    self.info=XmlDocument.parse(xmlText)
    adm.config.Write('LastUpdateCheck', time.time()) 
Example #18
Source File: updateChecker.py    From PyEveLiveDPS with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        try:
            httpResponse = urllib.request.urlopen("https://api.github.com/repos/ArtificialQualia/PyEveLiveDPS/releases").read()
        except urllib.error.URLError as e:
            logging.exception('Exception checking for new releases:')
            logging.exception(e)
            return
        
        releases = json.loads(httpResponse.decode('utf-8'))
        
        logging.info('Current version: ' + version.version)
        logging.info('Latest release: ' + releases[0]['name'])
        if releases[0]['name'] != version.version.split('-')[0] and releases[0]['name'] != settings.disableUpdateReminderFor:
            UpdateNotificaitonWindow(releases) 
Example #19
Source File: app.py    From freshonions-torscraper with GNU Affero General Public License v3.0 5 votes vote down vote up
def whatweb_list_json(name):
	version = request.args.get("version")
	account = request.args.get("account")
	string  = request.args.get("string")
	domains = WebComponent.find_domains(name, version=version, account=account, string=string)
	return jsonify(Domain.to_dict_list(domains)) 
Example #20
Source File: app.py    From freshonions-torscraper with GNU Affero General Public License v3.0 5 votes vote down vote up
def whatweb_list(name):
	version = request.args.get("version")
	account = request.args.get("account")
	string  = request.args.get("string")
	domains = WebComponent.find_domains(name, version=version, account=account, string=string)
	return render_template('whatweb_list.html', domains=domains, name=name, version=version, account=account, string=string) 
Example #21
Source File: app.py    From freshonions-torscraper with GNU Affero General Public License v3.0 5 votes vote down vote up
def src():
	version_string = version.version()
	source_name="torscraper-%s.tar.gz" % version_string
	source_link="/static/%s" % source_name
	return render_template('src.html', source_name=source_name, source_link=source_link) 
Example #22
Source File: app.py    From freshonions-torscraper with GNU Affero General Public License v3.0 5 votes vote down vote up
def inject_revision():
	return dict(revision=version.revision()) 
Example #23
Source File: payment_consumer.py    From tezos-reward-distributor with GNU General Public License v3.0 5 votes vote down vote up
def create_stats_dict(self, nb_failed, nb_injected, payment_cycle, payment_logs, total_attempts):
        n_f_type = len([pl for pl in payment_logs if pl.type == TYPE_FOUNDER])
        n_o_type = len([pl for pl in payment_logs if pl.type == TYPE_OWNER])
        n_d_type = len([pl for pl in payment_logs if pl.type == TYPE_DELEGATOR])
        n_m_type = len([pl for pl in payment_logs if pl.type == TYPE_MERGED])
        stats_dict = {}
        stats_dict['tot_amnt'] = int(sum([rl.amount for rl in payment_logs]) / 1e+9)  # in 1K tezos
        stats_dict['nb_pay'] = int(len(payment_logs) / 10)
        stats_dict['nb_failed'] = nb_failed
        stats_dict['nb_unkwn'] = nb_injected
        stats_dict['tot_attmpt'] = total_attempts
        stats_dict['nb_f'] = n_f_type
        stats_dict['nb_o'] = n_o_type
        stats_dict['nb_m'] = n_m_type
        stats_dict['nb_d'] = n_d_type
        stats_dict['cycle'] = payment_cycle
        stats_dict['m_fee'] = 1 if self.delegator_pays_xfer_fee else 0
        stats_dict['trdver'] = version.version
        if self.args:
            stats_dict['m_run'] = 1 if self.args.background_service else 0
            stats_dict['m_prov'] = 0 if self.args.reward_data_provider == 'tzscan' else 1
            m_relov = 0
            if self.args.release_override > 0:
                m_relov = 1
            elif self.args.release_override < 0:
                m_relov = -1
            stats_dict['m_relov'] = m_relov
            stats_dict['m_offset'] = 1 if self.args.payment_offset != 0 else 0
            stats_dict['m_clnt'] = 1 if self.args.docker else 0
        return stats_dict 
Example #24
Source File: service.py    From opensnitch with GNU General Public License v3.0 5 votes vote down vote up
def _on_diff_versions(self, daemon_ver, ui_ver):
        if self._version_warning_shown == False:
            self._msg.setIcon(QtWidgets.QMessageBox.Warning)
            self._msg.setWindowTitle("OpenSnitch version mismatch!")
            self._msg.setText(("You are running version <b>%s</b> of the daemon, while the UI is at version " + \
                              "<b>%s</b>, they might not be fully compatible.") % (daemon_ver, ui_ver))
            self._msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
            self._msg.show()
            self._version_warning_shown = True 
Example #25
Source File: prompt.py    From opensnitch with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent=None):
        QtWidgets.QDialog.__init__(self, parent, QtCore.Qt.WindowStaysOnTopHint)

        self.setupUi(self)

        self.setWindowTitle("OpenSnitch v%s" % version)

        self._cfg = Config.get()
        self._lock = threading.Lock()
        self._con = None
        self._rule = None
        self._local = True
        self._peer = None
        self._prompt_trigger.connect(self.on_connection_prompt_triggered)
        self._timeout_trigger.connect(self.on_timeout_triggered)
        self._tick_trigger.connect(self.on_tick_triggered)
        self._tick = self._cfg.default_timeout
        self._tick_thread = None
        self._done = threading.Event()

        self._apps_parser = LinuxDesktopParser()

        self._app_name_label = self.findChild(QtWidgets.QLabel, "appNameLabel")
        self._app_icon_label = self.findChild(QtWidgets.QLabel, "iconLabel")
        self._message_label = self.findChild(QtWidgets.QLabel, "messageLabel")

        self._src_ip_label = self.findChild(QtWidgets.QLabel, "sourceIPLabel")
        self._dst_ip_label = self.findChild(QtWidgets.QLabel, "destIPLabel")
        self._uid_label = self.findChild(QtWidgets.QLabel, "uidLabel")
        self._pid_label = self.findChild(QtWidgets.QLabel, "pidLabel")
        self._args_label = self.findChild(QtWidgets.QLabel, "argsLabel")

        self._apply_button = self.findChild(QtWidgets.QPushButton, "applyButton")
        self._apply_button.clicked.connect(self._on_apply_clicked)

        self._action_combo = self.findChild(QtWidgets.QComboBox, "actionCombo")
        self._what_combo = self.findChild(QtWidgets.QComboBox, "whatCombo")
        self._duration_combo = self.findChild(QtWidgets.QComboBox, "durationCombo") 
Example #26
Source File: parser.py    From artview with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def parse(argv):
    '''
    Parse the input command line.

    Parameters
    ----------
    argv - string
        Input command line string.

    Notes
    -----
    Returns directory and field for initialization.
    '''
    parser = argparse.ArgumentParser(
        description="Start ARTview - the ARM Radar Toolkit Viewer.")

    parser.add_argument('-v', '--version', action='version',
                        version='ARTview version %s' % (VERSION))

    # Directory argument now optional
    parser.add_argument('-d', '--directory', type=str,
                        help='Open specified directory', default=os.getcwd())
    parser.add_argument('-f', '--field', type=str,
                        help='Name of field to show on open',
                        default=None)
    parser.add_argument('-F', '--file', type=str,
                        help='File to show on open',
                        default=None)
    parser.add_argument(
        '-s', '--script', type=str, default=None,
        help=('Select from artview.scripts a script to execute. '
              'Possibilities include: standard, layout, grid, radar '))

    # Parse the args
    args = parser.parse_args(argv[1::])

    return args.script, args.directory, args.file, args.field 
Example #27
Source File: pdfwriter.py    From OpenRAM with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def write(self, file, writer, registry):
        if time.timezone < 0:
            # divmod on positive numbers, otherwise the minutes have a different sign from the hours
            timezone = "-%02i'%02i'" % divmod(-time.timezone/60, 60)
        elif time.timezone > 0:
            timezone = "+%02i'%02i'" % divmod(time.timezone/60, 60)
        else:
            timezone = "Z00'00'"

        def pdfstring(s):
            r = ""
            for c in s:
                if 32 <= ord(c) <= 127 and c not in "()[]<>\\":
                    r += c
                else:
                    r += "\\%03o" % ord(c)
            return r

        file.write("<<\n")
        if writer.title:
            file.write("/Title (%s)\n" % pdfstring(writer.title))
        if writer.author:
            file.write("/Author (%s)\n" % pdfstring(writer.author))
        if writer.subject:
            file.write("/Subject (%s)\n" % pdfstring(writer.subject))
        if writer.keywords:
            file.write("/Keywords (%s)\n" % pdfstring(writer.keywords))
        file.write("/Creator (PyX %s)\n" % version.version)
        file.write("/CreationDate (D:%s%s)\n" % (time.strftime("%Y%m%d%H%M"), timezone))
        file.write(">>\n") 
Example #28
Source File: SSHStore.py    From buttersink with GNU General Public License v3.0 5 votes vote down vote up
def version(self):
        """ Return kernel and btrfs version. """
        return dict(
            buttersink=theVersion,
            btrfs=self.butterStore.butter.btrfsVersion,
            linux=platform.platform(),
        ) 
Example #29
Source File: SSHStore.py    From buttersink with GNU General Public License v3.0 5 votes vote down vote up
def _open(self):
        """ Open connection to remote host. """
        if self._process is not None:
            return

        cmd = [
            'ssh',
            self._host,
            'sudo',
            'buttersink',
            '--server',
            '--mode',
            self._mode,
            self._directory
        ]
        logger.debug("Connecting with: %s", cmd)
        self._process = subprocess.Popen(
            cmd,
            stdin=subprocess.PIPE,
            stderr=sys.stderr,
            # stdout=sys.stdout,
            stdout=subprocess.PIPE,
        )

        version = self.version()
        logger.info("Remote version: %s", version) 
Example #30
Source File: pswriter.py    From OpenRAM with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def __init__(self, document, file):
        if len(document.pages) != 1:
            raise ValueError("EPS file can be constructed out of a single page document only")
        page = document.pages[0]
        canvas = page.canvas

        try:
            file.write("")
        except:
            filename = file
            if not filename.endswith(".eps"):
                filename += ".eps"
            try:
                file = open(filename, "w")
            except IOError:
                raise IOError("cannot open output file")
        else:
            filename = "stream"

        pagefile = cStringIO.StringIO()
        registry = PSregistry()
        acontext = context()
        pagebbox = bbox.empty()

        page.processPS(pagefile, self, acontext, registry, pagebbox)

        file.write("%!PS-Adobe-3.0 EPSF-3.0\n")
        if pagebbox:
            file.write("%%%%BoundingBox: %d %d %d %d\n" % pagebbox.lowrestuple_pt())
            file.write("%%%%HiResBoundingBox: %g %g %g %g\n" % pagebbox.highrestuple_pt())
        file.write("%%%%Creator: PyX %s\n" % version.version)
        file.write("%%%%Title: %s\n" % filename)
        file.write("%%%%CreationDate: %s\n" %
                   time.asctime(time.localtime(time.time())))
        file.write("%%EndComments\n")

        file.write("%%BeginProlog\n")
        registry.output(file, self)
        file.write("%%EndProlog\n")

        file.write(pagefile.getvalue())
        pagefile.close()

        file.write("showpage\n")
        file.write("%%Trailer\n")
        file.write("%%EOF\n")