Wednesday, 28 November 2018

How to use OR filters in djcli?

In djcli documentation they explain you can filter models like this with the list command:

$ djcli ls settings.AUTH_USER_MODEL is_staff=1 username email is_superuser
Auto-detected DJANGO_SETTINGS_MODULE=testproj2.settings
Auto-detected model=auth.User
-----  ------------  ---------
email  is_superuser  username
       True          newb
       False         13337noob
-----  ------------  ---------

But it does not show how to use the OR filter, ie. to list users that are either with is_staff=True, either is_superuser=True, is it possible ?

Otherwise, how do you recommend to propose a syntax for OR'ing filters so I can contribute to djcli ?



from How to use OR filters in djcli?

Xlib ConfigureRequest with custom configuration not working

I am using python and python3-xlib (which is a pure python implementation of the Xlib interface but basically is very similar to the C Xlib). For educational purposes, I am trying to create a simple window manager which should be able to force windows to have some specific sizes, when they are opened. In my example, I want to force the windows to have a width and height of 500px.

I listen for the ConfigureRequest event and for the MapRequest event. If I don't change width and height, but directly pass the hints of the opening window without changing them, to the window's configuration, everything works as expected.

However, when I specify a size that is not the intended size of the newly opening window, the MapRequest is delayed by more than 3 seconds (window becomes visible >3s after ConfigureRequest). This was the case, when I tested this using xterm. When I tested gnome-terminal, the MapRequest was fired before the ConfigureRequest, became immediately visible, but did not redraw (although I could close it by blindly typing exit Return).

This is obviously not the expected behavior. Am I doing anything wrong?

The relevant code:

def handle_event(self):
    try:
        event = self.display.next_event()
    except Xlib.error.ConnectionClosedError:
        print("The connection to display '"+self.display.get_display_name()+"' was closed by the server")
        print("Exiting now")
        sys.exit(0)
    if event.type in self.event_map:
        self.event_map[event.type](event) # calls on_configure_request or on_map_request depending on event type

.

def handle_configure_request(self, event):
    window = event.window
    args = { 'border_width': 3 }
    if event.value_mask & Xlib.X.CWX:
        args['x'] = event.x
    if event.value_mask & Xlib.X.CWY:
        args['y'] = event.y
    if event.value_mask & Xlib.X.CWWidth:
        args['width'] = event.width
    if event.value_mask & Xlib.X.CWHeight:
        args['height'] = event.height
    if event.value_mask & Xlib.X.CWSibling:
        args['sibling'] = event.above
    if event.value_mask & Xlib.X.CWStackMode:
        args['stack_mode'] = event.stack_mode
    args["width"] = 500
    args["height"] = 500
    window.configure(**args)
    print("Configured") # printed twice for every window -> is this normal?

.

def on_map_request(self, event):
    print("Mapping now") # when width and height are changed like above, this is printed more than 3s after on_configure_request when testing with xterm
    event.window.map()
    print("Mapped")



from Xlib ConfigureRequest with custom configuration not working

i have a problem with selecting some data from mysql database both side CSV

i have both side coma seperated values like

 $ing=1,2,3,4,5,6

and the database has a table with values

 IDS    5,2,1,6,2,3,45 // in database

i know this is not a good practice but i had to do this to get the values in one query. i also have a seperate table where the IDS are seperate and corrosponds to seperate users like

  user 1    IDS 2 
  user 3    IDS 65 etc 

As of now i am using

 $conditions[] = "CONCAT(',', `rcring`, ',') REGEXP ',($ing),'";

it gives me good results but it gives me the values in which either of the $ing exists i want only the tables which has atleast all the $ing

can you help me please i tried my work and i cant get a proper solution anywhere . thankx .



from i have a problem with selecting some data from mysql database both side CSV