예제 #1
0
파일: gitxp.py 프로젝트: sickless/gitxp
def get_rm_patch(filename, xpath):
    """ Returns string

        Returns the diff string which deletes the block content defined by the xpath
    """
    staged_content = get_file_content_from_stage(filename)
    backend_obj = backend.get_backend(filename)
    idx, rm_block_content = backend_obj.get_blocksequence_of_xpath(staged_content, xpath)
    # Get contexts before and after if possible
    new_context = []
    add_beginning_context = idx
    if add_beginning_context:
        beginning_context = staged_content[idx-1]
        new_context.append(beginning_context)
    ending_idx = idx+len(rm_block_content)
    add_ending_context = ending_idx < len(staged_content)
    if add_ending_context:
        ending_content = staged_content[idx+len(rm_block_content)]
        new_context.append(ending_content)
    # And insert it to make the patch applying properly
    if add_beginning_context:
        rm_block_content.insert(0, beginning_context)
    if add_ending_context:
        rm_block_content.append(ending_content)
    return get_patch(rm_block_content, new_context, idx, REMOVING_MODE, filename)
예제 #2
0
 def get_backend(self):
     """ For a record of backend, returns the appropriate instance
     of :py:class:`~connector.backend.Backend`.
     """
     self.ensure_one()
     if self._backend_type is None:
         raise ValueError('The backend %s has no _backend_type' % self)
     return backend.get_backend(self._backend_type, self.version)
예제 #3
0
파일: command.py 프로젝트: franckv/ptime
    def __init__(self):
        backend = get_backend(config)
        self.utils = Utils(backend)
        self.list = {}

        for func in dir(self):
            if func.startswith('do_'):
                f = getattr(Command, func)
                self.list[func[3:]] = {'args': len(inspect.getargspec(f).args) - 1, 'exec': f}
예제 #4
0
def search():
    backend = get_backend()
    eventlist = backend['events'].keys()
    eventlist.sort()
    query = request.args.get('query')
    if query:
        eventlist = search_events(query,backend)
    if request.args.get('f_friend') == 'True':
        for e in backend['events'].keys():
            if e in eventlist and backend['events'][e]['friends'] == 0:
                eventlist.remove(e)
    if request.args.get('f_faculty') == 'True':
        for e in backend['events'].keys():
            if e in eventlist and backend['events'][e]['badge_counts'][0] == 0:
                eventlist.remove(e)
    if request.args.get('f_research') == 'True':
        for e in backend['events'].keys():
            if e in eventlist and backend['events'][e]['badge_counts'][1] == 0:
                eventlist.remove(e)
    if request.args.get('f_clubs') == 'True':
            for e in backend['events'].keys():
                if e in eventlist and backend['events'][e]['badge_counts'][2] == 0:
                    eventlist.remove(e)
    if request.args.get('f_industry') == 'True':
        for e in backend['events'].keys():
            if e in eventlist and backend['events'][e]['badge_counts'][3] == 0:
                eventlist.remove(e)




    if request.method == 'POST': #this block is only entered when the form is submitted
        r = request.form
        print r
        if  'edit' in r: # attend event
            link = r['edit']
            e = backend['events'][link]
            e['title'] = r[link+'title']
            e['date'] = r[link+'date']
            e['location'] = r[link+'location']
            e['description'] = r[link+'description']
        if  'attend' in r: # attend event
            link = r['attend']
            e = backend['events'][link]
            if backend['logged_in']:
                e['attendees'].append(r[link+'name'])
                backend['users'][backend['user']]['events'].append(link)
            elif " + " + r[link+'name'] not in e['attendees']:
                e['attendees'].append(" + " + r[link+'name'])
        if  'unattend' in r: # attend event
            link = r['unattend']
            e = backend['events'][link]
            e['attendees'].remove(r[link+'name'])
            backend['users'][backend['user']]['events'].remove(link)
        set_backend(backend)

    return render_template('search.html', backend = backend, eventlist = eventlist)
예제 #5
0
 def __init__(self):
     Gtk.init_check(sys.argv)
     # create empty dialog
     self.dia_xml = Gtk.Builder()
     self.dia_xml.set_translation_domain("apturl")
     self.dia_xml.add_from_file('/usr/share/apturl/apturl-gtk.ui')
     self.dia = self.dia_xml.get_object('confirmation_dialog')
     self.dia.realize()
     self.backend = get_backend(self.dia)
     self.backend.connect("action-done", self._on_backend_done)
예제 #6
0
 def get_backend(self, cr, uid, id, context=None):
     """ For a record of backend, returns the appropriate instance
     of :py:class:`~connector.backend.Backend`.
     """
     if hasattr(id, '__iter__'):
         assert len(id) == 1, "One ID expected, %d received" % len(id)
         id = id[0]
     if self._backend_type is None:
         raise ValueError('The backend %s has no _backend_type' % self)
     backend_record = self.browse(cr, uid, id, context=context)
     return backend.get_backend(self._backend_type, backend_record.version)
예제 #7
0
    def get_backend(self, id):
        """ For a record of backend, returns the appropriate instance
        of :py:class:`backend.Backend`.
        """

        if self._backend_service is None:
            raise ValueError('The backend %s has no _backend_service' % self)

        backend_record = self.browse(id)
        return backend.get_backend(self._backend_service,
                                   backend_record.version)
예제 #8
0
    def get_backend(self, id):
        """ For a record of backend, returns the appropriate instance
        of :py:class:`backend.Backend`.
        """

        if self._backend_service is None:
            raise ValueError('The backend %s has no _backend_service' % self)

        backend_record = self.browse(id)
        return backend.get_backend(self._backend_service,
                                   backend_record.version)
예제 #9
0
파일: gitxp.py 프로젝트: sickless/gitxp
def get_checkout_patch(filename, xpath):
    """ Returns string

        Returns the diff string which deletes the block content defined by the xpath
    """
    HEAD_content = get_file_content_from_HEAD(filename)
    current_content = get_modified_file_content(filename)
    backend_obj = backend.get_backend(filename)
    _, HEAD_block_content = backend_obj.get_blocksequence_of_xpath(HEAD_content, xpath)
    current_idx, current_block_content = backend_obj.get_blocksequence_of_xpath(current_content, xpath)
    # We only need to know the current_idx to set properly
    # the patch even with changes done above in the file.
    return get_patch(current_block_content, HEAD_block_content, current_idx, ADDING_MODE, filename)
예제 #10
0
파일: gitxp.py 프로젝트: sickless/gitxp
def get_add_patch(filename, xpath):
    """ Returns string

        Returns the diff string from the xpath block of the filename
    """
    staged_content = get_file_content_from_stage(filename)
    current_content = get_modified_file_content(filename)
    backend_obj = backend.get_backend(filename)
    _, staged_block_content = backend_obj.get_blocksequence_of_xpath(staged_content, xpath)
    current_idx, current_block_content = backend_obj.get_blocksequence_of_xpath(current_content, xpath)
    # We only need to know the current_idx to set properly
    # the patch even with changes done above in the file.
    return get_patch(staged_block_content, current_block_content, current_idx, ADDING_MODE, filename)
예제 #11
0
파일: kivyui.py 프로젝트: franckv/ptime
    def build(self):
        self.screens = ScreenManager(transition=SlideTransition())
        self.screens.app = self
        self.screens.add_widget(MainScreen(name='main'))
        self.screens.add_widget(ProjectScreen(name='project'))
        self.screens.add_widget(CategoryScreen(name='category'))
        self.screens.add_widget(TaskScreen(name='task'))
        self.screens.current = 'main'

        backend = get_backend(config) 
        self.utils = Utils(backend)
        project = self.utils.get_default_project()
        self.set_project(project)

        categories = self.screens.get_screen('project')
        categories.grid.bind(minimum_height=categories.grid.setter('height'))

        return self.screens
예제 #12
0
def login():
    backend = get_backend()
    if backend['logged_in'] :
        print 'here'
        backend['user'] = None
        backend['logged_in'] = False
        print backend
        set_backend(backend)

    if request.method == 'POST': #this block is only entered when the form is submitted
        r = request.form
        if 'login' in r:
            backend['logged_in'] = True
            if request.form['username'] not in backend['users']:
                backend['user'] = '******'
            else:
                backend['user'] = request.form['username']
            set_backend(backend)
            return redirect("/"+backend['user'], code=302)
        if 'create' in r:
            backend['users'][r['link']] = {}
            u = backend['users'][r['link']]
            u['name'] = r['name']
            u['link'] = r['link']
            u['badges'] = [None,None,None,None]
            u['events'] = []
            u['email'] = r['email']
            u['about'] = ''
            u['friends'] = []
            if r['picture'] != '':
                u['picture'] = r['picture']
            else:
                u['picture'] = "https://bootdey.com/img/Content/avatar/avatar"+ str(random.choice([1,2,3,4,5,6,7,8])) + ".png"
            backend['user'] = r['link']
            backend['logged_in'] = True
            set_backend(backend)
            return redirect("/"+backend['user'], code=302)


    return render_template('login.html', backend = backend)
예제 #13
0
파일: gitxp.py 프로젝트: sickless/gitxp
def get_reset_patch(filename, xpath):
    """ Returns string

        Returns the diff string from the xpath block of the filename
    """
    HEAD_content = get_file_content_from_HEAD(filename)
    staged_content = get_file_content_from_stage(filename)
    backend_obj = backend.get_backend(filename)
    idx_HEAD, HEAD_block_content = backend_obj.get_blocksequence_of_xpath(HEAD_content, xpath)
    idx_staged, staged_block_content = backend_obj.get_blocksequence_of_xpath(staged_content, xpath)
    idx = idx_HEAD or idx_staged
    # Get contexts before and after if possible
    add_beginning_context = idx
    if add_beginning_context:
        beginning_context = staged_content[idx-1]
        staged_block_content.insert(0, beginning_context)
        HEAD_block_content.insert(0, beginning_context)
    ending_idx = idx+len(staged_block_content)
    add_ending_context = ending_idx < len(staged_content)
    if add_ending_context:
        ending_content = staged_content[idx+len(staged_block_content)-1]
        staged_block_content.append(ending_content)
        HEAD_block_content.append(ending_content)
    return get_patch(HEAD_block_content, staged_block_content, idx, ADDING_MODE, filename)
예제 #14
0
from labeless.logs import MyStdOut

# Redirect stderr and stdout to the backend's log window
if not isinstance(sys.stdout, MyStdOut):
    sys.stdout = MyStdOut(py_olly.std_out_handler)
if not isinstance(sys.stderr, MyStdOut):
    sys.stderr = MyStdOut(py_olly.std_err_handler)

# Assign a default sys.argv
sys.argv = [""]

# Have to make sure Python finds our modules

backend_name = py_olly.get_backend_info()['name']
from backend import get_backend
LB = get_backend(backend_name)
all_names = getattr(LB, '__all__') if hasattr(
    LB, '__all__') else (key for key in LB.__dict__ if not key.startswith('_'))

my_ns = globals()

for name in all_names:
    my_ns[name] = getattr(LB, name)

del backend_name
del all_names
del my_ns


class _DateTimeJsonSerializer(json.JSONEncoder):
    def default(self, obj):
예제 #15
0
"""
import schedule
import time

import logging
import signal
from backend import get_backend
from packetbeat import manage_packetbeat

log = logging.getLogger("dockeragent")
logging.basicConfig(level=logging.INFO)


def handler(signum, frame):
    exit(0)


signal.signal(signal.SIGINT, handler)

backend = get_backend()
backend.register_node()

# .run() is added to force scheduler to start the task right away, otherwise we have to wait
# for 30 seconds for first execution
schedule.every(30).seconds.do(backend.send_container_list).run()
schedule.every(15).seconds.do(manage_packetbeat).run()

while True:
    schedule.run_pending()
    time.sleep(1)
예제 #16
0
import platform
from backend import get_backend

os_name = platform.system()
os_backend = get_backend(os_name)()

print(os_backend.get_process_list())
예제 #17
0
# import rdebug
import py_olly
from labeless.logs import MyStdOut


# Redirect stderr and stdout to the backend's log window
if not isinstance(sys.stdout, MyStdOut):
    sys.stdout = MyStdOut(py_olly.std_out_handler)
if not isinstance(sys.stderr, MyStdOut):
    sys.stderr = MyStdOut(py_olly.std_err_handler)

# Assign a default sys.argv
sys.argv = [""]

# Have to make sure Python finds our modules

backend_name = py_olly.get_backend_info()['name']
from backend import get_backend
LB = get_backend(backend_name)
all_names = getattr(LB, '__all__') if hasattr(LB, '__all__') else (key for key in LB.__dict__ if not key.startswith('_'))

my_ns = globals()

for name in all_names:
    my_ns[name] = getattr(LB, name)

del backend_name
del all_names
del my_ns

예제 #18
0
def other_profile(something):
    backend = get_backend()
    if request.method == 'POST': #this block is only entered when the form is submitted
        r = request.form
        print r
        if  'edit' in r: # attend event
            link = r['edit']
            e = backend['events'][link]
            e['title'] = r[link+'title']
            e['date'] = r[link+'date']
            e['location'] = r[link+'location']
            e['description'] = r[link+'description']
        if  'attend' in r: # attend event
            link = r['attend']
            e = backend['events'][link]
            if backend['logged_in']:
                e['attendees'].append(r[link+'name'])
                backend['users'][backend['user']]['events'].append(link)
            elif " + " + r[link+'name'] not in e['attendees']:
                e['attendees'].append(" + " + r[link+'name'])

        if  'unattend' in r: # attend event
            link = r['unattend']
            e = backend['events'][link]
            e['attendees'].remove(r[link+'name'])
            backend['users'][backend['user']]['events'].remove(link)
        if 'edituser' in r:
            link = r['edituser']
            u = backend['users'][link]
            u['name'] = r[link+'name']
            u['picture'] = r[link+'picture']
            u['about'] = r[link+'about']
            u['email'] = r[link+'email']
            if r[link+'Faculty'] == '' or r[link+'Faculty'] == 'None':
                u['badges'][0] = None
            else:
                u['badges'][0] = r[link+'Faculty']
            if r[link+'Research'] == '' or r[link+'Research'] == 'None':
                u['badges'][1] = None
            else:
                u['badges'][1] = r[link+'Research']
            if r[link+'Clubs'] == '' or r[link+'Clubs'] == 'None':
                u['badges'][2] = None
            else:
                u['badges'][2] = r[link+'Clubs']
            if r[link+'Industry'] == '' or r[link+'Industry'] == 'None':
                u['badges'][3] = None
            else:
                u['badges'][3] = r[link+'Industry']
        if 'newevent' in r:
            url = create_url()
            while(url in backend['events']):
                url = create_url()
            backend['events'][url] = {}
            e = backend['events'][url]
            e['attendees'] = []
            e['host'] = backend['user']
            e['title'] = r['newtitle']
            e['date'] = r['newdate']
            e['description'] = r['newdescription']
            e['location'] = r['newlocation']
            e['img_src'] = ''
            e['link'] = url
            backend['users'][backend['user']]['events'].append(url)
            set_backend(backend)
            return redirect("/"+url, code=302)
        if 'delete' in r:
            link = r['delete']
            e = backend['events'][link]
            for user in e['attendees']:
                backend['users'][user]['events'].remove(link)
            backend['users'][e['host']]['events'].remove(link)
            del backend['events'][link]
            set_backend(backend)
            return redirect("/", code=302)
        if 'addfriend' in r:
            link = r['addfriend']
            u = backend['users'][link]
            u['friends'].append(r[link+'friend'])
            print u['friends']
        if 'unfriend' in r:
            link = r['unfriend']
            u = backend['users'][link]
            u['friends'].remove(r[link+'unfriend'])
            print u['friends']
        set_backend(backend)

    if something in backend['users']:
        user = something
        return render_template('profile.html', backend = backend, user=user)
    elif something in backend['events'] :
        event = something
        return render_template('event.html', backend = backend, event=backend['events'][event])
    else:
        return '404'