You are not logged in.

#51 2005-06-27 17:08:13

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

You can use Swing in Python. I don't think I'd recommend it. Now that I think of it, I would *never* write a GUI app in Python. Why? I don't know.  I would write a 3D app in Python, but not a typical desktop app. Go figure.

Dusty

Offline

#52 2005-06-27 20:46:58

xerxes2
Member
From: Malmoe, Sweden
Registered: 2004-04-23
Posts: 1,249
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

hehehe,
yet another pacman frontend,
my advice is to not spend so much time on it because it's not very wise to pipe pacman like this, better wait for libpacman

@Dusty
why sholdn't you write a gui program in python? you can use both gtk and qt, python/pygtk is so good that you can write a clone of abiword in a week(or two) in it,


arch + gentoo + initng + python = enlisy

Offline

#53 2005-06-27 20:49:41

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

My problem is I don't like gtk, qt, pygtk, wxpython, or tkinter... :-/

Offline

#54 2005-06-27 20:51:27

xerxes2
Member
From: Malmoe, Sweden
Registered: 2004-04-23
Posts: 1,249
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

what's the problem with gtk?
it's a bit complicated i admit but pygtks manual are really really good,


arch + gentoo + initng + python = enlisy

Offline

#55 2005-06-27 20:57:57

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

I don't know what I didn't like about it... I confess it was kind of a snap judgement... gtk doesn't seem very object oriented, I guess.

It doesn't really matter with me though, because I've kind of quit developing GUI applications. I prefer CLI or 3D.  I'm looking into python's CGKit though...

Dusty

Offline

#56 2005-06-27 21:01:42

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

xerxes2 wrote:

hehehe,
yet another pacman frontend,
my advice is to not spend so much time on it because it's not very wise to pipe pacman like this, better wait for libpacman

I'm interested as to why it's less preferable to excute, say,  "pacman -S mypkg" via a GUI front-end, than typing the same command from the shell. I personally like the idea of a GUI simply being a "window" to good ol' pacman, rather than completely concealing it. But that's just me. libpacman sure would provide a more graceful solution but not make much difference from the users' perspective.

There's been a lot of talk about libpacman opening the doors to an influx of front-ends. But will it ever appear? Do all programmers write in C?

Offline

#57 2005-06-27 21:33:43

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

a lib-pacman implementation would be waaaaaay faster than executing sequential pacman calls because it would do everything in-process. Well, most things. Some things.

I suspect that when a libpacman has arrived, people will be making python, ruby, java etc etc etc modules to wrap it.

Will it ever appear? Its being worked on at the rate of Arch. So... eventually.

Dusty

Offline

#58 2005-06-27 21:45:57

xerxes2
Member
From: Malmoe, Sweden
Registered: 2004-04-23
Posts: 1,249
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

arooaroo wrote:
xerxes2 wrote:

hehehe,
yet another pacman frontend,
my advice is to not spend so much time on it because it's not very wise to pipe pacman like this, better wait for libpacman

I'm interested as to why it's less preferable to excute, say,  "pacman -S mypkg" via a GUI front-end, than typing the same command from the shell. I personally like the idea of a GUI simply being a "window" to good ol' pacman, rather than completely concealing it. But that's just me. libpacman sure would provide a more graceful solution but not make much difference from the users' perspective.

There's been a lot of talk about libpacman opening the doors to an influx of front-ends. But will it ever appear? Do all programmers write in C?

pacman is not meant for piping, you are extracting pacmans output as strings and start work from there, it's possible but it's ugly,


arch + gentoo + initng + python = enlisy

Offline

#59 2005-06-27 21:54:13

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

arooaroo wrote:

There's been a lot of talk about libpacman opening the doors to an influx of front-ends. But will it ever appear? Do all programmers write in C?

It will be a C lib, but in less than a day I could pop out SWIG wrappers for python, ruby, and lua (for you ion-ites) and do some JNI crap for you guys.... assuming I'm motivated enough

Offline

#60 2005-06-27 21:57:31

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

xerxes2 wrote:

pacman is not meant for piping, you are extracting pacmans output as strings and start work from there, it's possible but it's ugly,

That's not quite the case with Jacman. Pacman is only called at the end, after the user hits the Install/Remove/Update buttons within their respective dialogs. The acquisition of package data is loaded manually by accessing the repository databases themselves. This is very easy to parse due to the structure used within the package description files. %NAME% and all that. Jacman sends a single command to pacman at the end after the user has selected a package, for example, and hits Install.

Offline

#61 2005-06-27 21:59:31

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

mrm.... then its not really a frontend to pacman, its actually more like a reimplementation of some parts of it... ;-)

Offline

#62 2005-06-27 22:01:36

xerxes2
Member
From: Malmoe, Sweden
Registered: 2004-04-23
Posts: 1,249
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

aha, i second dusty here,
this is the start of your own pacman library written in java, that's how i started libpypac,
i suggest you put everything in one file which you can call from the gui,

Disclaimer: i don't know java but i assume it works like python,


arch + gentoo + initng + python = enlisy

Offline

#63 2005-06-27 22:06:45

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

But I see Pacman as a package manager. All I've implemented is how to search for packages on the system or packages available for install. This is not anything crucial. Installng/removing/updating - now that's what Pacman is really all about. And that is the stuff I won't be touching in Jacman.

As you said Xerxes, parsing pacman output is ugly, (and slow), therefore I'd be stupid not to bypass this part. And load from the source itself.

Offline

#64 2005-06-27 22:11:59

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

Its a hybrid! Its not a good thing to try to classify stuff. ;-)

Dusty

Offline

#65 2005-06-27 22:12:39

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

xerxes2 wrote:

Disclaimer: i don't know java but i assume it works like python,

And I don't know Haskell, so I'll just assume it works like COBOL, heh

Offline

#66 2005-06-27 22:15:04

xerxes2
Member
From: Malmoe, Sweden
Registered: 2004-04-23
Posts: 1,249
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

hmm, then it should work pretty good i guess,

you are smarter than i thoght smile


arch + gentoo + initng + python = enlisy

Offline

#67 2005-06-27 22:21:23

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

xerxes2 wrote:

hmm, then it should work pretty good i guess,

you are smarter than i thoght smile

Back-handed complements - they're my favourite wink

Offline

#68 2005-06-27 23:28:52

soniX
Member
From: Oslo, Norway
Registered: 2004-01-23
Posts: 161

Re: Jacman 0.1 - Java GUI front-end to pacman

Just had a good time playing with your jacman code..
and I wrote a little patch which makes the output pretty much like pacman with "ILoveCandy" enabled...
(This is the first time I used the diff tool, so if I got anything wrong, please let me know....It worked here atleast)

EDIT: ooops.. just realised that this code wont work UNLESS you have ILoveCandy enabled in pacman.conf

Update 1: patch now makes print behave like ILoveCandy if you have ILoveCandy enabled in /etc/pacman.conf.. If you dont, it will print like normal pacman..

--- src/andyr/jacman/console/ConsoleDialog.java    2005-06-27 23:38:40.000000000 +0100
+++ /home/teijon/workspace/Jacman/src/andyr/jacman/console/ConsoleDialog.java    2005-06-28 13:17:58.000000000 +0100
@@ -1,11 +1,14 @@
 package andyr.jacman.console;
 import java.awt.BorderLayout;
 import java.awt.Dialog;
-import java.awt.Frame;
+import java.awt.Font;
 import java.awt.HeadlessException;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.io.BufferedReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
 
 import javax.swing.JButton;
 import javax.swing.JDialog;
@@ -54,6 +57,8 @@
             
             outputArea = new JTextArea(20,80);
             outputArea.setText("");
+            //set monospaced font so prints doesnt get skewed
+            outputArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
             outputArea.setEditable(false);
             
             consolePanel.add(new JScrollPane(outputArea));
@@ -97,7 +102,6 @@
     
 
     private void runCommand(String[] command) {
-        Run run = new Run();
         //String[] cmd = {command, "-l", "/dev"};
         outputArea.append("# ");
         
@@ -109,20 +113,101 @@
         //Scroll along with the output
         outputArea.setCaretPosition(outputArea.getText().length()-1);
         try {
-            BufferedReader[] outputs = run.it(command , null , null,true);
+            BufferedReader[] outputs = Run.it(command , null , null,true);
             String stdoutput = "";
+            
+            String lastName = "";
+            boolean iLovecandy = false;
+            int nameColumnWidth = 20;
+            int percentColumnWidth = 4;
+            int sizeColumnWidth = 8;
+            int speedColumnWidth = 8;
+            
             while (stdoutput != null) {
-                String line = "    "+stdoutput+"n";
+                
+                String line = "  "+stdoutput+"n";
+                StringTokenizer tok = new StringTokenizer(stdoutput);
+                int tokens =tok.countTokens();
+                
+                
+                //if there are 6 or 7 tokens, then its most likely a download we should track
+                //6 tokens => ILoveCandy
+                //7 tokens => default pacman output
+                if(tokens==6||tokens==7){
+                    try{
+                        //set iLoveCandy status on the first valid download run only
+                        if(lastName.equals(""))
+                            iLovecandy=tokens==6;
+                        List<String> elements = new ArrayList<String>();
+                        while(tok.hasMoreTokens()){
+                            elements.add(tok.nextToken());
+                        }
+                        //name of package/repo-list we are downloading
+                        String name = elements.get(0);
+                        for(int i=name.length();i<nameColumnWidth;i++)
+                            name+=" ";
+                        
+                        //percent downloaded
+                        String percentBuf = elements.get(tokens==6?2:3);
+                        int percent = Integer.parseInt(percentBuf.substring(0,percentBuf.length()-1));
+                        String percentString="";
+                        for(int i=percentBuf.length();i<percentColumnWidth;i++)
+                            percentString+=" ";
+                        percentString+=percentBuf;
+                        
+                        //size downloaded
+                        String kBuf = elements.get(tokens==6?3:4);
+                        String k="";
+                        for(int i=kBuf.length();i<sizeColumnWidth;i++)
+                            k+=" ";
+                        k+=kBuf;
+                        
+                        //downloadspeed
+                        String speedBuf = elements.get(tokens==6?4:5);
+                        String speed="";
+                        for(int i=speedBuf.length();i<speedColumnWidth;i++)
+                            speed+=" ";
+                        speed+=speedBuf;
+                        
+                        //time
+                        String time = elements.get(tokens==6?5:6);
+                        
+                        //ascii-progressbar emulation for both regular and iLoveCandy themed pacman
+                        String progress = "[";
+                        int i;
+                        for(i=1;i<percent/5;i++)
+                            progress+=iLovecandy?"-":"#";
+                        progress+=iLovecandy?percent<100?i%2==0?"C":"c":"-":"#";
+                        for(int j=i;j<20;j++)
+                            progress+=iLovecandy?"*":" ";
+                        progress+="]";
+                        
+                        //the line we are going to append
+                        line = name+"  "+progress+"  "+percentString+"  "+k+"  "+speed+"  "+time+"n";
+                        
+                        //remove last line in texarea if it has the same name as the current element
+                        if(name.trim().equals(lastName.trim()))
+                        {
+                            int index = outputArea.getText().lastIndexOf(lastName.trim());
+                            outputArea.setText(outputArea.getText().substring(0,index));
+                        }
+                        //set current name to lastname for next roundtrip
+                        lastName = name;
+                    } catch(Exception e){
+                        //if something happens, fall back to normal printing for this element
+                        //e.printStackTrace();
+                    }
+                }//end if( tokens==6 || tokens==7 )
+                    
                 outputArea.append(line);
-                
                 outputArea.setCaretPosition(outputArea.getText().length()-line.length());
+                
                 stdoutput = outputs[0].readLine();
             }
             String stderr = "";
             while (stderr != null) {
-                String line = "    "+stderr+"n";
+                String line = "  "+stderr+"n";
                 outputArea.append(line);
-                
                 outputArea.setCaretPosition(outputArea.getText().length()-line.length());
                 stderr = outputs[1].readLine();
             }

Offline

#69 2005-06-27 23:51:28

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: Jacman 0.1 - Java GUI front-end to pacman

arooaroo: no, did you look at my screenshot? there was another issue.

https://iphitus.no-ip.org/jacman.png

it's passing --ignore to pacman, which in this case is an option it doesnt support.

Offline

#70 2005-06-28 10:48:50

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

iphitus wrote:

it's passing --ignore to pacman, which in this case is an option it doesnt support.

Yuk! How did I miss that beast of a bug! I'll get on to that asap. Thanks for spotting.

EDIT:

I'm most confused as to how you're getting that "empty" package. I will add some logic to the package loading methods to try and ensure that these empty packages can't get added in the first place.

Offline

#71 2005-06-28 14:36:48

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

Last night I dreamed I borrowed some code from jacman and made a 3D pacman interface for Ensmer.

Dusty

Offline

#72 2005-06-28 14:42:12

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

Dusty wrote:

Last night I dreamed I borrowed some code from jacman and made a 3D pacman interface for Ensmer.

Dusty

lol

That's a sign that you need to take a break from computing!

Offline

#73 2005-06-28 14:49:29

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

oh... I thought it was a sign to see if you were sure you were gonna release jacman under the GPL, because Ensmer is licensed Apache... but then, I could make the Enspacman (ensman? pacsmer?) classes GPL, since they'd be pluggable, and not a direct part of Ensmer.

Yeah... geez, I gotta finish fixing up EnsmerMail and get onto this!

Dusty

Offline

#74 2005-06-29 12:30:49

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: Jacman 0.1 - Java GUI front-end to pacman

soniX wrote:

Just had a good time playing with your jacman code..
and I wrote a little patch which makes the output pretty much like pacman with "ILoveCandy" enabled...
(This is the first time I used the diff tool, so if I got anything wrong, please let me know....It worked here atleast)

EDIT: ooops.. just realised that this code wont work UNLESS you have ILoveCandy enabled in pacman.conf

Update 1: patch now makes print behave like ILoveCandy if you have ILoveCandy enabled in /etc/pacman.conf.. If you dont, it will print like normal pacman..

I've just tried out this patch and I'm pleased to say it's looking good! It solves that rather unpleasant artifact of rendering the curses-based download progress info as a massive list of newlines. Nice one Sonix!

Fortunately, I've modified the PacmanConf class that reads in /etc/pacman.conf to recongise the ILoveCandy option. So, you can obtain this property from this class rather than trying to determine if it's been enabled by analysing the output. I will probably rewrite some of the code too. Simply because Sonix uses a different style than me, e.g., I never use ?, even for simple conditions.

I've now got to think of a nice way of dealing with the two output streams from a Process (stdout and stderr). When updating, if you have IgnorePkg in your conf, pacman displays this info before the downloading/updating commences - but the message goes via stderr. In the Run class used by Jacman, stderr is outputted after stdout, and so you see this message after pacman has completed the update! This is not intuitive. I shall see what happens if I output both streams simultaneously.

Offline

#75 2005-06-29 13:54:06

sudman1
Member
From: Huntingdon, UK
Registered: 2005-02-18
Posts: 143

Re: Jacman 0.1 - Java GUI front-end to pacman

Actually, the Run class puts both outputs into real-time streams.  In my basic implementation, I only read the stdout in realtime, then read the stderr afterward. I never tried reading both at the same time, fearing that waiting for stderr would keep the stdout from updating in the same thread. A seperate thread for reading/printing stderr should output in real-time.


v/r
Suds

Offline

Board footer

Powered by FluxBB