コード例 #1
0
ファイル: test_version.py プロジェクト: muromec/qtopia-ezx
class FirstDigitZero( unittest.TestCase ):
    def setUp( self ):
        self.base = Version( '0.0.1' )
        
    def testGetMajor( self ):
        assertEquals( 'Major version number' ,
                      self.base.getMajor(),
                      0 )
      
    def testGetMinor( self ):
        assertEquals( 'Minor version number' ,
                      self.base.getMinor(),
                      0 )
                      
    def testGetPatch( self ):
        assertEquals( 'Patch level' ,
                      self.base.getPatch(),
                      1 )
              
    def testGetAddendum( self ):
        assertEquals( 'Addendum' ,
                      self.base.getAddendum(),
                      None )
                      
    def testPrintVersion( self ):
        verString = "%s" % self.base
        assertEquals( 'Version string' ,
                      verString,
                      '0.0.1' )
                      
    def testGetVersionNoAddendum( self ):
        verString = self.base.getVersionNoAddendum()
        assertEquals( 'Version string - no add' ,
                      verString,
                      '0.0.1' )
コード例 #2
0
ファイル: test_version.py プロジェクト: muromec/qtopia-ezx
class TwoDigit( unittest.TestCase ):
    def setUp( self ):
        self.base = Version( '6.4-foob' )
        
    def testGetMajor( self ):
        assertEquals( 'Major version number' ,
                      self.base.getMajor(),
                      6 )
      
    def testGetMinor( self ):
        assertEquals( 'Minor version number' ,
                      self.base.getMinor(),
                      4 )
                      
    def testGetPatch( self ):
        assertEquals( 'Patch level' ,
                      self.base.getPatch(),
                      0 )
              
    def testGetAddendum( self ):
        assertEquals( 'Addendum' ,
                      self.base.getAddendum(),
                      'foob' )
                      
    def testPrintVersion( self ):
        verString = "%s" % self.base
        assertEquals( 'Version string' ,
                      verString,
                      '6.4-foob' )
                      
    def testGetVersionNoAddendum( self ):
        verString = self.base.getVersionNoAddendum()
        assertEquals( 'Version string - no add' ,
                      verString,
                      '6.4' )
コード例 #3
0
ファイル: test_version.py プロジェクト: muromec/qtopia-ezx
class TwoDashAdd( unittest.TestCase ):
    def setUp( self ):
        self.base = Version( '3.2.1-devel-test-twodash' )
        
    def testGetMajor( self ):
        assertEquals( 'Major version number' ,
                      self.base.getMajor(),
                      3 )
      
    def testGetMinor( self ):
        assertEquals( 'Minor version number' ,
                      self.base.getMinor(),
                      2 )
                      
    def testGetPatch( self ):
        assertEquals( 'Patch level' ,
                      self.base.getPatch(),
                      1 )
              
    def testGetAddendum( self ):
        assertEquals( 'Addendum' ,
                      self.base.getAddendum(),
                      'devel-test-twodash' )
                      
    def testPrintVersion( self ):
        verString = "%s" % self.base
        assertEquals( 'Version string' ,
                      verString,
                      '3.2.1-devel-test-twodash' )
                      
    def testGetVersionNoAddendum( self ):
        verString = self.base.getVersionNoAddendum()
        assertEquals( 'Version string - no add' ,
                      verString,
                      '3.2.1' )
コード例 #4
0
ファイル: test_version.py プロジェクト: muromec/qtopia-ezx
class QueryTestCaseNoAddendum( unittest.TestCase ):
    def setUp( self ):
        self.base = Version( '3.5.2' )
        
    def testGetMajor( self ):
        assertEquals( 'Major version number' ,
                      self.base.getMajor(),
                      3 )
      
    def testGetMinor( self ):
        assertEquals( 'Minor version number' ,
                      self.base.getMinor(),
                      5 )
                      
    def testGetPatch( self ):
        assertEquals( 'Patch level' ,
                      self.base.getPatch(),
                      2 )
              
    def testGetAddendum( self ):
        assertEquals( 'Addendum' ,
                      self.base.getAddendum(),
                      None )
                      
    def testPrintVersion( self ):
        verString = "%s" % self.base
        assertEquals( 'Version string' ,
                      verString,
                      '3.5.2' )

    def testGetVersionNoAddendum( self ):
        verString = self.base.getVersionNoAddendum()
        assertEquals( 'Version string - no add' ,
                      verString,
                      '3.5.2' )
コード例 #5
0
ファイル: test_version.py プロジェクト: muromec/qtopia-ezx
class MixedVersionNumber( unittest.TestCase ):
    def setUp( self ):
        self.base = Version( '2.4.4c1' )
        
    def testGetMajor( self ):
        assertEquals( 'Major version number' ,
                      self.base.getMajor(),
                      2 )
      
    def testGetMinor( self ):
        assertEquals( 'Minor version number' ,
                      self.base.getMinor(),
                      4 )
                      
    def testGetPatch( self ):
        assertEquals( 'Patch level' ,
                      self.base.getPatch(),
                      4 )
              
    def testGetAddendum( self ):
        assertEquals( 'Addendum' ,
                      self.base.getAddendum(),
                      'c1' )
                      
    def testPrintVersion( self ):
        verString = "%s" % self.base
        assertEquals( 'Version string' ,
                      verString,
                      '2.4.4-c1' )
                      
    def testGetVersionNoAddendum( self ):
        verString = self.base.getVersionNoAddendum()
        assertEquals( 'Version string - no add' ,
                      verString,
                      '2.4.4' )
コード例 #6
0
ファイル: test_version.py プロジェクト: timbo-rafa/version
    def test_major(self):
        v1 = Version("11.0.0")
        v2 = Version("12.0.0")
        v3 = Version("v11.99.99rc99")

        assert v2 > v1
        assert v2 > v3
コード例 #7
0
 def setUp(self):
     version_1_string = self.load_xml_string_from_file(
         self.file_test_version_1_A)
     self.version_1 = Version(ET.fromstring(version_1_string))
     version_2_string = self.load_xml_string_from_file(
         self.file_test_version_2_A)
     self.version_2 = Version(ET.fromstring(version_2_string))
コード例 #8
0
def self_update():
    with open("VERSION") as v:
        cur_version = Version(v.read())
    with request.urlopen(
            "https://github.com/c-ffeestain/timewidget/raw/main/VERSION") as f:
        new_version = Version(f.read())
    if cur_version < new_version:
        print("Current version:", cur_version, "\n", "New version:",
              new_version)
        choice = input(
            "Outdated version, would you like to download the newest one (Y/n)? "
        ).lower()
        if choice == "y":
            cur_path = Path(__file__).parent
            wdt_exe = cur_path / "widget.exe"
            cfg_exe = cur_path / "config.exe"
            print("Backing up executables...")

            wdt_exe = wdt_exe.rename(wdt_exe.stem + ".backup" + wdt_exe.suffix)
            cfg_exe = cfg_exe.rename(cfg_exe.stem + ".backup" + cfg_exe.suffix)

            print(
                "Executables backed up as {} and {}. Downloading new version now!"
                .format(wdt_exe.name, cfg_exe.name))
            request.urlretrieve(
                "https://github.com/c-ffeestain/timewidget/releases/latest/download/widget.exe",
                "widget.exe")
            request.urlretrieve(
                "https://github.com/c-ffeestain/timewidget/releases/latest/download/config.exe",
                "config.exe")

            print("Running new exe...")
            Popen([str(wdt_exe)])
コード例 #9
0
ファイル: cmd_restore.py プロジェクト: 84danielwhite/tklbam
def do_compatibility_check(backup_turnkey_version, interactive=True):

    backup_codename = Version.from_string(backup_turnkey_version).codename
    local_codename = Version.from_system().codename

    if local_codename == backup_codename:
        return

    def fmt(s):
        return s.upper().replace("-", " ")

    backup_codename = fmt(backup_codename)
    local_codename = fmt(local_codename)

    print "WARNING: INCOMPATIBLE APPLIANCE BACKUP"
    print "======================================"
    print
    print "Restoring a %s backup to a %s appliance is not recommended." % (backup_codename, local_codename)
    print "For best results, restore to a fresh %s installation instead." % backup_codename

    if not interactive:
        sys.exit(ExitCode.INCOMPATIBLE)

    print
    print "(Use --force to suppress this check)"
    print

    while True:
        answer = raw_input("Do you want to continue? [yes/no] ")
        if answer:
            break

    if answer.lower() not in ('y', 'yes'):
        fatal("You didn't answer 'yes'. Aborting!")
コード例 #10
0
ファイル: test_version.py プロジェクト: timbo-rafa/version
    def test_different_formats_should_be_equal(self):
        v1 = Version(2)
        v2 = Version("2")
        v3 = Version(2.000000)
        v4 = Version("v0002.0.000000")

        assert v1 == v2 == v3 == v4
コード例 #11
0
ファイル: test_version.py プロジェクト: timbo-rafa/version
    def test_patch(self):
        v1 = Version("v11.11.19")
        v2 = Version("v11.11.2")
        v3 = Version("v11.11.09")

        assert v1 > v2
        assert v1 > v3
コード例 #12
0
ファイル: test_version.py プロジェクト: timbo-rafa/version
    def test_minor(self):
        v1 = Version("v22.0.0")
        v2 = Version("v22.1.0")
        v3 = Version("v22.0.9")

        assert v2 > v1
        assert v2 > v3
コード例 #13
0
ファイル: loadcommander.py プロジェクト: ra75/macholibre
    def parse_load_dylib(self, lc):
        offset = get_int(self.f)
        timestamp = get_int(self.f)
        current_version = get_int(self.f)
        compatibility_version = get_int(self.f)

        if self.macho.is_little():
            offset = little(offset, 'I')
            timestamp = little(timestamp, 'I')
            current_version = little(current_version, 'I')
            compatibility_version = little(compatibility_version, 'I')

        timestamp = datetime.fromtimestamp(timestamp)
        current_version = Version(version=current_version)
        compatibility_version = Version(version=compatibility_version)

        dylib = strip(self.f.read(lc.size - 24))
        self.macho.add_dylib(dylib)

        lc.add_data('timestamp', str(timestamp))
        lc.add_data('current_version', current_version.version)
        lc.add_data('compatibility_version', compatibility_version.version)
        lc.add_data('dylib', dylib)

        self.macho.add_lc(lc)
コード例 #14
0
 def test_copy_constructor(self):
     v = Version(Version([1, 2, 3, 4, 5]))
     self.assertEqual(v.major, 1)
     self.assertEqual(v.minor, 2)
     self.assertEqual(v.tiny, 3)
     self.assertEqual(v.micro, 4)
     self.assertEqual(v.nano, 5)
コード例 #15
0
ファイル: tests.py プロジェクト: marshall/pynaries
	def testFromString(self):
		v = Version.fromObject("1.3.3sp1")
		self.assertEquals(v.major, 1)
		self.assertEquals(v.minor, '3')
		self.assertEquals(v.micro, '3sp1')
		self.assertEquals(Version.getNumericPiece(v.micro), '3')
		self.assertEquals(Version.getAnnotationPiece(v.micro), 'sp1')
		self.assertEquals(str(v), "1.3.3sp1")
コード例 #16
0
def get_valid_version(version_str: str, build_dir: str) -> str:
    build_version = get_build_version(build_dir)
    str_version = re.search(r'^([0-9\.]+)', version_str).group(1)
    if Version(build_version, ignore_trailing_zero=True) != Version(
            str_version, ignore_trailing_zero=True):
        return build_version
    else:
        return version_str
コード例 #17
0
class Pipeline:
    """
    Create a new or load an existing pipeling.

    See Version for kwargs.

    Examples:

    Create a new pipeline.

    ```
    p = Pipeline(<version_id>)
    ```
    
    Execute the current state and then update position to next state.
    
    ```
    p.proceed()
    ```

    States:

    Each state implements a `proceed` method, which must call 
    `pipeline.update()`. For example:

    ```
    class Label:
        def __init__(self, pipeline):
            self.pipeline = pipeline

        def proceed(self):
            # Do stuff
            self.pipeline.update()
    ```
    """
    def __init__(self, version_id, **kwargs):
        self.version = Version(self, version_id, **kwargs)
        self.states = self.load_states()

    def get_pos(self):
        return self.version.config['pos']

    def load_states(self):
        states = self.version.config['states']
        return [eval(s)(self) for s in states]

    def get_state(self, offset=0):
        return self.states[self.get_pos() + offset]

    def proceed(self):
        try:
            self.states[self.get_pos()].proceed()
        except IndexError:
            print('The End')

    def update(self):
        self.version.update_config(('pos', self.get_pos() + 1))
        print(f'Updated state to {self.get_state()}')
コード例 #18
0
ファイル: test_version.py プロジェクト: wlonk/version
def test_comparing_against_non_version():

    with raises(TypeError) as exception:
        Version('1.0.0') > None
    assert 'cannot compare' in repr(exception.value)

    with raises(TypeError) as exception:
        Version('1.0.0') == object()
    assert 'cannot compare' in repr(exception.value)
コード例 #19
0
ファイル: git_utils.py プロジェクト: dimagi/mobile-deploy
def update_manifest_hotfix_version(file_contents):
    versionPattern = re.compile(r'android:versionName="(\d+).(\d+).(\d+)"')
    result = versionPattern.search(file_contents)
    if result is None or len(result.groups()) != 3:
        raise
    version_raw = list(map(int, result.groups()))
    version = Version(*version_raw)
    current_version = 'android:versionName="{}"'.format(version)
    next_version = 'android:versionName="{}"'.format(version.get_next_hotfix())
    return file_contents.replace(current_version, next_version)
コード例 #20
0
    def __init__(self, versionRanges):
        # For soup/direct maven index:
        self.versions = []
        if not isinstance(versionRanges, basestring):
            for vr in versionRanges:
                self.versions.append(Version(vr))
        else:
            self.versions.append(Version(versionRanges))

        self.versionRanges = versionRanges
コード例 #21
0
def archive_old_release_job(base_job_name, version):
    two_release_ago = Version(version.major, version.minor - 2, 0)
    last_release_job_name = '{}-{}'.format(base_job_name,
                                           two_release_ago.short_string())

    print("moving {} to {} view".format(last_release_job_name,
                                        ARCHIVED_MOBILE_VIEW_NAME))

    remove_job_from_view(last_release_job_name, MOBILE_VIEW_NAME)
    add_job_to_view(last_release_job_name, ARCHIVED_MOBILE_VIEW_NAME)
コード例 #22
0
ファイル: jenkins_utils.py プロジェクト: dimagi/mobile-deploy
def archive_old_release_job(base_job_name, version):
    two_release_ago = Version(version.major, version.minor - 2, 0)
    last_release_job_name = '{}-{}'.format(base_job_name,
                                           two_release_ago.short_string())

    print("moving {} to {} view".format(last_release_job_name,
                                        ARCHIVED_MOBILE_VIEW_NAME))

    remove_job_from_view(last_release_job_name, MOBILE_VIEW_NAME)
    add_job_to_view(last_release_job_name, ARCHIVED_MOBILE_VIEW_NAME)
コード例 #23
0
def update_manifest_hotfix_version(file_contents):
    versionPattern = re.compile(r'android:versionName="(\d+).(\d+).(\d+)"')
    result = versionPattern.search(file_contents)
    if result is None or len(result.groups()) != 3:
        raise
    version_raw = list(map(int, result.groups()))
    version = Version(*version_raw)
    current_version = 'android:versionName="{}"'.format(version)
    next_version = 'android:versionName="{}"'.format(version.get_next_hotfix())
    return file_contents.replace(current_version, next_version)
コード例 #24
0
    def test_merge_with_self_and_self_produces_self(self):
        version_1_copy_string_1 = self.load_xml_string_from_file(
            self.file_test_version_1_A)
        version_1_copy_1 = Version(ET.fromstring(version_1_copy_string_1))
        version_1_copy_string_2 = self.load_xml_string_from_file(
            self.file_test_version_1_A)
        version_1_copy_2 = Version(ET.fromstring(version_1_copy_string_2))

        version_1_copy_1.merge_with(version_1_copy_1, version_1_copy_2)
        self.assertTrue(
            self.version_1.version_semantically_equal_to(version_1_copy_1))
コード例 #25
0
    def test_change_version_details(self):
        v = Version('7.1', 'gpconcept-family')

        self.assertEqual('7.1', v.get_number())
        self.assertEqual('gpconcept-family', v.get_name())

        v.set_name('gpcms-family')
        v.set_number('7.10')

        self.assertEqual('7.10', v.get_number())
        self.assertEqual('gpcms-family', v.get_name())
コード例 #26
0
ファイル: libreoffice.py プロジェクト: mdhowle/version
def get_latest_version(site):
    data = urllib.request.urlopen(site)
    p = LinkParser()
    p.feed(data.read().decode('utf-8'))

    latest = Version('0.0')
    for link in p.links:
        ver = Version(link)
        if latest < ver:
            latest = ver
    return latest
コード例 #27
0
 def isSL(self, x=None):
     """ if x is given: returns True if os == Scientific Linux x
         if x is not given: returns a Version instance with the SL version
         otherwise returns False """
     if( self.type == "Linux" ):
         if( self.ver.find( "Scientific" ) != -1 or self.ver.find( "RedHat" ) != -1):
             if x != None:
                 return Version( self.ver )[0] == x
             else:
                 return Version( self.ver )
     return False
コード例 #28
0
def pkg(message):
    """Outputs a message with a package icon."""
    import platform
    from version import Version

    mac_ver = platform.mac_ver()[0]
    if mac_ver and Version(mac_ver) >= Version('10.7'):
        print u"\U0001F4E6" + indent,
    else:
        cwrite('@*g{[+]} ')
    print message
コード例 #29
0
ファイル: test_version.py プロジェクト: wlonk/version
def test_section_3():
    """Section 3.

    When a major version number is incremented, the minor
    version and patch version MUST be reset to zero. When a
    minor version number is incremented, the patch version
    MUST be reset to zero. For instance: 1.1.3 -> 2.0.0 and
    2.1.7 -> 2.2.0.

    """
    assert Version('1.1.3') < Version('2.0.0')
    assert Version('2.1.7') < Version('2.2.0')
コード例 #30
0
    def __init__(self, filename):
        '''
        Read a PSCF symmetry-adapted field file, and create a new object.

        Argument:
        filename -- name of file

        The file named filename is opened and closed within this function.
        '''
        self.file = open(filename, 'r')
        self._io = IO()
        file = self.file

        # Read version line
        self.version = Version(self.file)

        self._input_unit_cell()
        self.group_name = self._input_var('char')
        self.N_monomer = self._input_var('int')
        self.N_star = self._input_var('int')

        # Define empty lists
        self.fields = []
        self.waves = []
        self.counts = []

        for i in range(self.N_star):

            data = file.readline().split()
            if len(data) != self.N_monomer + self.dim + 1:
                raise IoException('Incorrect number of elements in field line')
            j = 0

            # Read field coefficients
            self.fields.append([])
            for k in range(self.N_monomer):
                value = float(data[j])
                self.fields[i].append(value)
                j += 1

            # Read field coefficients
            self.waves.append([])
            for k in range(self.dim):
                value = int(data[j])
                self.waves[i].append(value)
                j += 1

            # Read star_count
            self.counts.append(int(data[j]))

        self.file.close()
        self.file = None
コード例 #31
0
ファイル: notepad++.py プロジェクト: mdhowle/version
def get_latest(site, directory):
    with ftplib.FTP() as ftp:
        ftp.connect(site)
        ftp.login()
        files = ftp.mlsd(directory)
        latest = Version(0.0)
        for file in files:
            if file[0] in ('.', '..'):
                continue

            if latest < file[0]:
                latest = Version(file[0])
    return latest
コード例 #32
0
def run(argv=None):
    if not argv:
        # Ignore program name
        argv = sys.argv[1:]

    if len(argv) < 4:
        sys.stderr.write(
            "Please input three files and specify an output location")
        exit(-1)

    output_filename = argv[3]

    base_filename = argv[0]
    ours_filename = argv[1]
    theirs_filename = argv[2]

    tree_base = ET.parse(argv[0])
    tree_out = ET.parse(argv[0])
    tree_ours = ET.parse(argv[1])
    tree_theirs = ET.parse(argv[2])

    root_base = tree_base.getroot()
    root_out = tree_out.getroot()
    root_ours = tree_ours.getroot()
    root_theirs = tree_theirs.getroot()

    base_version = Version(root_base)
    our_version = Version(root_ours)
    their_version = Version(root_theirs)

    base_version.merge_with(our_version, their_version)

    base_version.write(output_filename)
コード例 #33
0
ファイル: registry.py プロジェクト: 84danielwhite/tklbam
def _complete_profile_id(partial):
    if not re.match(r"^turnkey-", partial):
        partial = "turnkey-" + partial

    partial = Version.from_string(partial)
    system = Version.from_system()

    if partial.arch is None:
        partial.arch = system.arch

    if partial.release is None or system.release.startswith(partial.release):
        partial.release = system.release

    return str(partial)
コード例 #34
0
    def test_change_version_details(self):
        v = Version('7.1', 'gpconcept-family')

        self.assertEqual('7.1', v.get_number())
        self.assertEqual('gpconcept-family', v.get_name())

        v.set_name('gpcms-family')
        v.set_number('7.10')

        self.assertEqual('7.10', v.get_number())
        self.assertEqual('gpcms-family', v.get_name())
コード例 #35
0
ファイル: test_version.py プロジェクト: wlonk/version
def test_section_11():
    """Section 11: Build version.

    A build version MAY be denoted by appending a plus sign
    and a series of dot separated identifiers immediately
    following the patch version or pre-release version.
    Identifiers MUST be comprised of only ASCII
    alphanumerics and dash [0-9A-Za-z-]. Build versions
    satisfy and have a higher precedence than the associated
    normal version. Examples: 1.0.0+build.1,
    1.3.7+build.11.e0f985a.

    """
    assert Version('1.0.0+build.1').build == ['build', 1]
    assert Version('1.0.0+build.11.e0f985a').build == ['build', 11, 'e0f985a']
コード例 #36
0
 def test_string_constructor(self):
     v = Version.from_string('1.2.3.4.5')
     self.assertEqual(v.major, 1)
     self.assertEqual(v.minor, 2)
     self.assertEqual(v.tiny, 3)
     self.assertEqual(v.micro, 4)
     self.assertEqual(v.nano, 5)
コード例 #37
0
 def test_from_list(self):
     v = Version.from_iterable([1, 2, 3, 4, 5])
     self.assertEqual(v.major, 1)
     self.assertEqual(v.minor, 2)
     self.assertEqual(v.tiny, 3)
     self.assertEqual(v.micro, 4)
     self.assertEqual(v.nano, 5)
コード例 #38
0
 def test_get_by_int(self):
     v = Version(1, 2, 3, 4, 5)
     self.assertEqual(v[0], v.major)
     self.assertEqual(v[1], v.minor)
     self.assertEqual(v[2], v.tiny)
     self.assertEqual(v[3], v.micro)
     self.assertEqual(v[4], v.nano)
コード例 #39
0
ファイル: bundle.py プロジェクト: marshall/pynaries
	def __init__(self, id, op=GreaterThan, version="0.0.0"):
		self.id = id
		self.op = op
		self.version = Version.fromObject(version)
		self.resolution = None
		self.resolvedSite = None
		self.error = False
コード例 #40
0
    def __init__(self, args):
        # Load the database
        home = expanduser("~")
        with open(home + '/.hackertray.json', 'a+') as content_file:
            content_file.seek(0)
            content = content_file.read()
            try:
                self.db = set(json.loads(content))
            except ValueError:
                self.db = set()

        # create an indicator applet
        self.ind = appindicator.Indicator("Hacker Tray", "hacker-tray", appindicator.CATEGORY_APPLICATION_STATUS)
        self.ind.set_status(appindicator.STATUS_ACTIVE)
        self.ind.set_icon(get_icon_filename("hacker-tray.png"))

        # create a menu
        self.menu = gtk.Menu()

        # The default state is false, and it toggles when you click on it
        self.commentState = args.comments

        # create items for the menu - refresh, quit and a separator
        menuSeparator = gtk.SeparatorMenuItem()
        menuSeparator.show()
        self.menu.append(menuSeparator)

        btnComments = gtk.CheckMenuItem("Show Comments")
        btnComments.show()
        btnComments.set_active(args.comments)
        btnComments.connect("activate", self.toggleComments)
        self.menu.append(btnComments)

        btnAbout = gtk.MenuItem("About")
        btnAbout.show()
        btnAbout.connect("activate", self.showAbout)
        self.menu.append(btnAbout)

        btnRefresh = gtk.MenuItem("Refresh")
        btnRefresh.show()
        # the last parameter is for not running the timer
        btnRefresh.connect("activate", self.refresh, True, args.chrome)
        self.menu.append(btnRefresh)

        if Version.new_available():
            btnUpdate = gtk.MenuItem("New Update Available")
            btnUpdate.show()
            btnUpdate.connect('activate', self.showUpdate)
            self.menu.append(btnUpdate)

        btnQuit = gtk.MenuItem("Quit")
        btnQuit.show()
        btnQuit.connect("activate", self.quit)
        self.menu.append(btnQuit)

        self.menu.show()

        self.ind.set_menu(self.menu)
        self.refresh(chrome_data_directory=args.chrome, firefox_data_directory=args.firefox)
        self.launch_analytics(args)
コード例 #41
0
ファイル: registry.py プロジェクト: 84danielwhite/tklbam
    def _update_profile(self, profile_id=None):
        """Get a new profile if we don't have a profile in the registry or the Hub
        has a newer profile for this appliance. If we can't contact the Hub raise
        an error if we don't already have profile."""

        hub_backups = hub.Backups(self.sub_apikey)
        if not profile_id:
            if self.profile:
                profile_id = self.profile.profile_id
            else:
                profile_id = str(Version.from_system())

        if self.profile and self.profile.profile_id == profile_id:
            profile_timestamp = self.profile.timestamp
        else:
            # forced profile is not cached in the self
            profile_timestamp = None

        try:
            new_profile = hub_backups.get_new_profile(profile_id, profile_timestamp)
            if new_profile:
                self.profile = new_profile
                print "Downloaded %s profile" % self.profile.profile_id

        except hub_backups.Error, e:
            errno, errname, desc = e.args
            if errname == "BackupArchive.NotFound":
                raise self.ProfileNotFound(desc)

            if not self.profile or (self.profile.profile_id != profile_id):
                raise

            raise self.CachedProfile("using cached profile because of a Hub error: " + desc)
コード例 #42
0
 def test_int_constructor(self):
     v = Version(1)
     self.assertEqual(v.major, 1)
     self.assertEqual(v.minor, 0)
     self.assertEqual(v.tiny, 0)
     self.assertEqual(v.micro, 0)
     self.assertEqual(v.nano, 0)
コード例 #43
0
 def test_get_by_string(self):
     v = Version(1, 2, 3, 4, 5)
     self.assertEqual(v['major'], v.major)
     self.assertEqual(v['minor'], v.minor)
     self.assertEqual(v['tiny'], v.tiny)
     self.assertEqual(v['micro'], v.micro)
     self.assertEqual(v['nano'], v.nano)
コード例 #44
0
	def __init__(self, version_string, derived=None):
		assert isinstance(version_string, basestring), "Expected string, got %s" % (type(version_string))
		self.upstream = version_string
		if derived is None:
			derived = Version.parse(version_string, coerce=True)
		assert isinstance(derived, Version)
		self.derived = derived
コード例 #45
0
ファイル: __init__.py プロジェクト: artiya4u/hackertray
 def launch_analytics(self, args):
     # Now that we're all done with the boot, send a beacone home
     launch_data = vars(args)
     launch_data['version'] = Version.current()
     launch_data['platform'] = platform.linux_distribution()
     try:
         launch_data['browser'] = subprocess.check_output(["xdg-settings", "get", "default-web-browser"]).strip()
     except subprocess.CalledProcessError as e:
         launch_data['browser'] = "unknown"
コード例 #46
0
    def __init__(self, fileName, numEdits, fileSize, lastEdited):
        self.fileName = fileName
        self.localVersion = Version(fileName, numEdits, fileSize, lastEdited)
        self.latestVersion = self.localVersion.copy()

        self.numChunksOwned = 0
        self.chunksOwned = [False] * self.localVersion.numChunks
        self.state = ""
        self.readCounter = 0
        self.isDeleted = False
コード例 #47
0
ファイル: jenkins_utils.py プロジェクト: dimagi/mobile-deploy
def get_latest_release_job_version():
    """
    Reads the version number off of the commcare-android job, and use it to
    find the hotfix version in the latest commcare-android-X.XX job.
    """
    master_xml = j.get_job_config('commcare-android')

    versionPattern = re.compile(r'VERSION=(\d+).(\d+).(\d+)')
    next_version_raw = versionPattern.search(master_xml).groups()
    if len(next_version_raw) != 3:
        raise Exception("Couldn't find next version to deploy")
    next_version = Version(*map(int, next_version_raw))

    last_version = next_version.get_last_version_short()
    staged_release_job = 'commcare-android-{}'.format(last_version)
    release_xml = j.get_job_config(staged_release_job)
    current_version_raw = versionPattern.search(release_xml).groups()
    if len(current_version_raw) != 3:
        raise Exception("Couldn't find next version to deploy")
    return Version(*map(int, current_version_raw))
コード例 #48
0
ファイル: __init__.py プロジェクト: captn3m0/hackertray
def main():
    parser = argparse.ArgumentParser(description='Hacker News in your System Tray')
    parser.add_argument('-v','--version', action='version', version=Version.current())
    parser.add_argument('-c','--comments', dest='comments',action='store_true', help="Load the HN comments link for the article as well")
    parser.add_argument('--chrome', dest='chrome', help="Specify a Google Chrome Profile directory to use for matching chrome history")
    parser.add_argument('--firefox', dest='firefox', help="Specify a Firefox Profile directory to use for matching firefox history")
    parser.add_argument('--dnt', dest='dnt',action='store_true', help="Disable all analytics (Do Not Track)")
    parser.set_defaults(comments=False)
    parser.set_defaults(dnt=False)
    args = parser.parse_args()
    indicator = HackerNewsApp(args)
    indicator.run()
コード例 #49
0
ファイル: distro.py プロジェクト: wangweiqing/dogtail
 def getVersion(self, packageName):
     if not self.cache:
         import apt_pkg
         apt_pkg.init()
         self.cache = apt_pkg.Cache()
     packages = self.cache.packages
     for package in packages:
         if package.name == packageName:
             verString = re.match(
                 '.*Ver:\'(.*)-.*\' Section:', str(package.current_ver)).group(1)
             return Version.fromString(verString)
     raise PackageNotFoundError(packageName)
コード例 #50
0
ファイル: fieldfile.py プロジェクト: dmorse/pscf
    def __init__(self,filename):
        '''
        Read a PSCF symmetry-adapted field file, and create a new object.

        Argument:
        filename -- name of file

        The file named filename is opened and closed within this function.
        '''
        self.file = open(filename, 'r')
	self._io   = IO()
	file = self.file

        # Read version line
	self.version = Version(self.file)

        self._input_unit_cell()
        self.group_name = self._input_var('char')
        self.N_monomer = self._input_var('int')
        self.N_star = self._input_var('int')

        # Define empty lists
        self.fields = []
        self.waves = []
        self.counts = []

        for i in range(self.N_star):

            data = file.readline().split()
            if len(data) != self.N_monomer + self.dim + 1:
                raise IoException('Incorrect number of elements in field line')
            j = 0

            # Read field coefficients
            self.fields.append([])
            for k in range(self.N_monomer):
                value = float(data[j])
                self.fields[i].append(value)
                j += 1

            # Read field coefficients
            self.waves.append([])
            for k in range(self.dim):
                value = int(data[j])
                self.waves[i].append(value)
                j += 1

            # Read star_count
            self.counts.append(int(data[j]))

        self.file.close()
	self.file = None
コード例 #51
0
ファイル: bioplot.py プロジェクト: josbouten/bioplot
def parseArguments():
    v = Version()
    progName = basename(sys.argv[0])
    version = "This is bioplot.py version %s, Copyright (C) 2014: Jos Bouten" % v.getVersion()
    parser = argparse.ArgumentParser(description="%s [plot type] [<label1> <label2> <label3> ...]\n\
    bioplot.py version %s.\n\
    This program comes with ABSOLUTELY NO WARRANTY; for details run `bioplot.py -l\'.\n\
    This is free software, and you are welcome to redistribute it\n\
    under certain conditions; type `bioplot.py -l\' for details.\n\
    This program was written by Jos Bouten.\n\
    You can contact me via josbouten at gmail dot com." % (progName, version))
    parser.add_argument('-Z', '--zoo', action="store_true", dest="plotZoo", help="show zoo plot")
    parser.add_argument('-A', '--accuracy', action="store_true", dest="plotAccuracy", help="show accuracy plot")
    parser.add_argument('-D', '--det', action="store_true", dest="plotDet", help="show Det plot")
    parser.add_argument('-E', '--eer', action="store_true", dest="plotEer", help="show EER plot")
    parser.add_argument('-T', '--tippet', action="store_true", dest="plotTippet", help="show Tippett plot")
    parser.add_argument('-M', '--matrix', action="store_true", dest="plotMatrix", help="show matrix plot")
    parser.add_argument('-O', '--roc', action="store_true", dest="plotRoc", help="show roc plot")
    parser.add_argument('-R', '--ranking', action="store_true", dest="plotRanking", help="show ranking plot")
    parser.add_argument('-C', '--histogramc', action="store_true", dest="plotHistCum", help="show cumulative histogram")
    parser.add_argument('-H', '--histogram', action="store_true", dest="plotHist", help="show histogram")
    parser.add_argument('-k', '--kernel', action="store_true", dest="plotKernel",
                        help="show kernel estimate in histogram")
    parser.add_argument('-L', '--label', dest='labels', type=str, nargs='+', help="add labels to plot")
    parser.add_argument('-e', '--exp', action="store", dest="expName", default='test',
                        help="name of experiment used in plot title, default = test")
    parser.add_argument('-i', '--inputfile', action="store", dest="filenames", nargs='+',
                        default=['input/testdata_A.txt'],
                        help="filename of filenames of data file(s) or name of database, default = input/testdata_A.txt")
    parser.add_argument('-t', '--type', action="store", dest="dataType", default='type3',
                        help="type of data, default = type3, use 'database' if you want to read data from a database.")
    parser.add_argument('-d', '--threshold', action="store", dest="threshold", type=float, default=0.7,
                        help="system threshold for ranking plot, default = 0.7")
    parser.add_argument('-c', '--config', action="store", dest="configFilename", default='bioplot.cfg',
                        help="use alternative config file")
    parser.add_argument('-l', '--license', action="store_true", dest="showLicense", help="show license")
    parser.add_argument('-s', '--settings', action="store_true", dest="showOptions", help="show settings only")
    parser.add_argument('-q', '--quiet', action="store_true", dest="quiet", help="do not show settings")
    return parser.parse_args()
コード例 #52
0
ファイル: registry.py プロジェクト: 84danielwhite/tklbam
    def update_profile(self, profile_id=None):
        try:
            # look for exact match first
            self._update_profile(profile_id)
        except self.ProfileNotFound, first_exception:
            if profile_id and not Version.from_string(profile_id).is_complete():
                completed_profile_id = _complete_profile_id(profile_id)
                try:
                    self._update_profile(completed_profile_id)
                except:
                    pass

            raise first_exception
コード例 #53
0
ファイル: jenkins_utils.py プロジェクト: dimagi/mobile-deploy
def inc_minor_version(job_name):
    """
    Bump the VERSION build parameter by a minor version.
    """
    print(("Incrementing the minor version # on " +
           "{} jenkins job").format(job_name))
    xml = j.get_job_config(job_name)
    versionPattern = re.compile(r'VERSION=(\d+).(\d+).(\d+)')
    current_version_raw = versionPattern.search(xml).groups()

    if len(current_version_raw) != 3:
        raise Exception("Couldn't parse version")
    current_version = Version(*map(int, current_version_raw))
    next_minor_version = current_version.get_next_minor_release()

    print('changing {} version reference {} to {}'.format(job_name,
                                                          current_version,
                                                          next_minor_version))

    xml = xml.replace("VERSION={}".format(current_version),
                      "VERSION={}".format(next_minor_version))

    j.reconfig_job(job_name, xml)
コード例 #54
0
ファイル: jenkins_utils.py プロジェクト: dimagi/mobile-deploy
def inc_hotfix_version_on_job(base_job_name, version):
    """
    Bump the commcare-android VERSION build parameter of a release job by a
    hotfix version.
    """
    job_name = "{}-{}".format(base_job_name, version.short_string())
    xml = j.get_job_config(job_name)
    versionPattern = re.compile(r'VERSION=(\d+).(\d+).(\d+)')
    current_version_raw = versionPattern.search(xml).groups()

    if len(current_version_raw) != 3:
        raise Exception("Couldn't parse version")
    current_version = Version(*map(int, current_version_raw))
    next_hotfix_version = current_version.get_next_hotfix()

    print('changing {} version reference {} to {}'.format(job_name,
                                                          current_version,
                                                          next_hotfix_version))

    xml = xml.replace("VERSION={}".format(current_version),
                      "VERSION={}".format(next_hotfix_version))

    j.reconfig_job(job_name, xml)
コード例 #55
0
ファイル: config_converter.py プロジェクト: PlanetHunt/satgen
 def convert_file(self, file_address, written_file_name=False):
     """
     Get the txt file and convert it to the
     shelx config file, returns the generated
     config file name as string. suffix will be added
     if a file with a same name exist.
     """
     version = Version()
     version_tag = version.get_version()
     f = self.read_file(file_address)
     if(written_file_name):
         written_file = open(written_file_name, 'w')
     else:
         written_file = open(
             self.get_file_container(f)["name"] + ".cfg", 'w')
     file_name = written_file.name
     written_file.write(
         "#Config file generated by SatGen V. " + version_tag)
     for line in list(f):
         if(not re.search("Date", line)):
             line = re.sub(":", "=", line)
         if(re.search("Date", line)):
             line = re.sub("(?<=[^0-9]):", "=", line.strip())
         line = re.sub("\[ ", "[", line)
         line = re.sub(" \]", "]", line)
         line = line.strip()
         line = line + "\n"
         try:
             written_file.write(line)
             self.log.debug(written_file.name + " is written to the disk!")
         except IOError as e:
             self.log.error(
                 "I/O error({0}): {1}".format(e.errno, e.strerror))
             raise
     written_file.close()
     f.close
     return file_name
コード例 #56
0
ファイル: bundle.py プロジェクト: marshall/pynaries
	def matchesVersion(self, version):
		if not self.op is InRange:
			v = Version.fromObject(version)
			if self.op is GreaterThanEqual:
				return v >= self.version
			elif self.op is GreaterThan:
				return v > self.version
			elif self.op is LessThanEqual:
				return v <= self.version
			elif self.op is LessThan:
				return v < self.version
			elif self.op is Equal:
				return v == self.version
		else:
			versionRange = []
			if isinstance(version, list):
				versionRange = version
			else:
				r = re.compile("[,\\-\\:]")
				versionRange = re.split(r, version)
			
			if self.version > Version.fromObject(versionRange[0]) and self.version < Version.fromObject(versionRange[1]):
				return True
			return False
コード例 #57
0
ファイル: distro.py プロジェクト: wangweiqing/dogtail
 def getVersion(self, packageName):
     # the portage utilities are almost always going to be in
     # /usr/lib/portage/pym
     import sys
     sys.path.append('/usr/lib/portage/pym')
     import portage
     # FIXME: this takes the first package returned in the list, in the
     # case that there are slotted packages, and removes the leading
     # category such as 'sys-apps'
     gentooPackageName = portage.db["/"][
         "vartree"].dbapi.match(packageName)[0].split('/')[1]
     # this removes the distribution specific versioning returning only the
     # upstream version
     upstreamVersion = portage.pkgsplit(gentooPackageName)[1]
     # print "Version of package is: " + upstreamVersion
     return Version.fromString(upstreamVersion)
コード例 #58
0
 def _getVersion(self, version_tag):
     """
     Return Version instance or None if version number is not exists.
     """
     assert version_tag is not None
     try:
         number = version_tag.get(u'number')
         status = version_tag.get(u'status')
         if number is None:
             raise ValueError
         full_number = (u' '.join([number, status]) if status is not None
                        else number)
         version = Version.parse(full_number)
     except ValueError:
         return None
     return version
コード例 #59
0
ファイル: api.py プロジェクト: dkelll/salesforce-python-sdk
    def __init__(self, **kwargs):
        super(Salesforce, self).__init__()

        self.__api = None

        self.__sandbox = None
        self.__soap = None
        self.__httplib = None
        self.__version = None
        self.__domain = None

        self.sandbox = kwargs.get('sandbox', False)
        self.soap = kwargs.get('soap', False)
        self.httplib = kwargs.get('httplib', Requests())
        self.domain = kwargs.get('domain', 'test' if self.sandbox else 'login')
        self.version = kwargs.get('version', Version.get_latest_version(self.httplib))

        self.__api = self.__get_api(self.soap)