示例#1
0
def initialize():
    commands.import_commands()

    # check we are inside a git repo
    try:
        common.find_repo_root()
    except common.GitRepoNotFound, error:
        print error
        sys.exit(1)
示例#2
0
def initialize():
    commands.import_commands()

    # check we are inside a git repo
    try:
        common.find_repo_root()
    except common.GitRepoNotFound, error:
        print error
        sys.exit(1)
示例#3
0
    def _build_issuedb(self):
        self._issuedb = {}

        # get current head
        current_head = common.git_repo.current_head()

        # check if we have cache for current head
        path = os.path.join(common.find_repo_root(),
                            '.git',
                            'gitissius.%s%s.cache' %\
                            (current_head,
                             '.colorama' if common.colorama else ''
                             )
                            )
        loaded = False

        if os.path.exists(path):
            with open(path) as flp:
                try:
                    self._issuedb = pickle.load(flp)
                    loaded = True

                except:
                    loaded = False

        if not loaded:
            for issue in common.git_repo.keys():
                if not '/comments/' in issue:
                    # making sure that we don't treat comments as issues
                    obj = Issue.load(json.loads(common.git_repo[issue]))
                    self._issuedb[str(obj.get_property('id'))] = obj


            # delete previous caches
            for fln in os.listdir(os.path.join(common.find_repo_root(),
                                              '.git')
                                 ):
                if fln.startswith('gitissius') and fln.endswith('.cache'):
                    os.remove(os.path.join(common.find_repo_root(),
                                           '.git',
                                           fln)
                              )

            # create new
            with open(path, "wb") as flp:
                pickle.dump(self._issuedb, flp)
示例#4
0
    def _build_issuedb(self):
        self._issuedb = {}

        # get current head
        current_head = common.git_repo.current_head()

        # check if we have cache for current head
        path = os.path.join(common.find_repo_root(),
                            '.git',
                            'gitissius.%s%s.cache' %\
                            (current_head,
                             '.colorama' if common.colorama else ''
                             )
                            )
        loaded = False

        if os.path.exists(path):
            with open(path) as flp:
                try:
                    self._issuedb = pickle.load(flp)
                    loaded = True

                except:
                    loaded = False

        if not loaded:
            for issue in common.git_repo.keys():
                if not '/comments/' in issue:
                    # making sure that we don't treat comments as issues
                    obj = Issue.load(json.loads(common.git_repo[issue]))
                    self._issuedb[str(obj.get_property('id'))] = obj

            # delete previous caches
            for fln in os.listdir(os.path.join(common.find_repo_root(),
                                               '.git')):
                if fln.startswith('gitissius') and fln.endswith('.cache'):
                    os.remove(
                        os.path.join(common.find_repo_root(), '.git', fln))

            # create new
            with open(path, "wb") as flp:
                pickle.dump(self._issuedb, flp)
示例#5
0
def main(is_test):
    if is_test:
        import FakeSevenSegment
        display = FakeSevenSegment.FakeSevenSegment()
    else:
        # Create display instance on default I2C address (0x70) and bus number.
        from Adafruit_LED_Backpack import SevenSegment
        display = SevenSegment.SevenSegment()

    # Initialize the display. Must be called once before using the display.
    display.begin()
    display.clear()
    display.write_display()

    # Read the certificate/key pair.
    repo_root = common.find_repo_root()
    certs_dir = os.path.join(repo_root, 'certs')
    with open(os.path.join(certs_dir, 'server.key')) as f:
        private_key = f.read()
    with open(os.path.join(certs_dir, 'server.crt')) as f:
        certificate_chain = f.read()
    server_credentials = grpc.ssl_server_credentials(((
        private_key,
        certificate_chain,
    ), ))

    server = grpc.server(futures.ThreadPoolExecutor(max_workers=1))
    servicer = SevenSegmentDisplayServicer(display)
    segment7_pb2_grpc.add_SevenSegmentDisplayServicer_to_server(
        servicer, server)

    config = common.read_config()
    _, port = config.get_segment7_host()
    address = '[::]:%d' % port
    server.add_secure_port(address, server_credentials)

    server.start()
    print('PID=%d Server started on %s' % (os.getpid(), address))
    try:
        while True:
            signal.pause()
    except KeyboardInterrupt:
        pass
    servicer.shutdown()
    server.stop(0)
示例#6
0
        else:
            # save current branch name
            branch = gitshelve.git('name-rev', '--name-only',
                                   'HEAD') or 'master'

            # stash changes
            try:
                gitshelve.git('stash')

            except gitshelve.GitError, error:
                pass

            # create an empty repo
            gitshelve.git('symbolic-ref', 'HEAD', 'refs/heads/gitissius')
            cwd = common.find_repo_root()
            os.unlink(os.path.join(cwd, '.git', 'index'))
            gitshelve.git('clean', '-fdx')
            gitshelve.git('commit', '--allow-empty', '-m', 'Initialization')
            gitshelve.git('checkout', branch)

            try:
                gitshelve.git('stash', 'pop')

            except gitshelve.GitError, error:
                pass

        # open the repo now, since init was done
        common.git_repo = gitshelve.open(branch='gitissius')

示例#7
0
            gitshelve.git('branch', 'gitissius', 'origin/gitissius')

        else:
            # save current branch name
            branch = gitshelve.git('name-rev', '--name-only', 'HEAD') or 'master'

            # stash changes
            try:
                gitshelve.git('stash')

            except gitshelve.GitError, error:
                pass

            # create an empty repo
            gitshelve.git('symbolic-ref', 'HEAD', 'refs/heads/gitissius')
            cwd = common.find_repo_root()
            os.unlink(os.path.join(cwd, '.git', 'index'))
            gitshelve.git('clean', '-fdx')
            gitshelve.git('commit', '--allow-empty', '-m', 'Initialization')
            gitshelve.git('checkout', branch)

            try:
                gitshelve.git('stash', 'pop')

            except gitshelve.GitError, error:
                pass

        # open the repo now, since init was done
        common.git_repo = gitshelve.open(branch='gitissius')

def close():