예제 #1
0
        public PyObject Encode()
        {
            if (cache == null)
            {
                Log.Error("PyCachedObject", "Cache data is null");
                return null;
            }

            if (objectID == null)
            {
                Log.Error("PyCachedObject", "objectID is null");
                return null;
            }

            PyTuple args = new PyTuple();

            PyTuple versiont = new PyTuple();
            versiont.Items.Add(new PyLongLong(timestamp));
            versiont.Items.Add(new PyInt(version));

            args.Items.Add(versiont);
            args.Items.Add(new PyNone());
            args.Items.Add(new PyInt(nodeID));
            args.Items.Add(new PyInt(shared));
            args.Items.Add(cache);
            args.Items.Add(new PyInt(compressed));
            args.Items.Add(objectID);

            return new PyObjectData("objectCaching.CachedObject", args);
        }
예제 #2
0
 public void TestStringIsTupleType()
 {
     using (Py.GIL())
     {
         var s = new PyString("foo");
         Assert.IsFalse(PyTuple.IsTupleType(s));
     }
 }
예제 #3
0
 public void TestPyTupleEmpty()
 {
     using (Py.GIL())
     {
         var t = new PyTuple();
         Assert.AreEqual(0, t.Length());
     }
 }
예제 #4
0
 public void SendServiceCall(int characterID, string service, string call, PyTuple args, PyDictionary namedPayload,
                             Action <RemoteCall, PyDataType> callback, Action <RemoteCall> timeoutCallback = null, object extraInfo = null, int timeoutSeconds = 0)
 {
     this.ClientSendServiceCall(
         this.AccountDB.GetAccountIDFromCharacterID(characterID),
         service, call, args, namedPayload, callback, timeoutCallback, extraInfo, timeoutSeconds
         );
 }
예제 #5
0
        public void TupleMarshal_Empty()
        {
            PyTuple tuple = new PyTuple(0);

            byte[] output = Marshal.Marshal.ToByteArray(tuple, false);

            Assert.AreEqual(sTupleMarshaling_Empty, output);
        }
예제 #6
0
 public void TestPyTupleIsTupleType()
 {
     using (Py.GIL())
     {
         var t = new PyTuple();
         Assert.IsTrue(PyTuple.IsTupleType(t));
     }
 }
예제 #7
0
 public override PyInteger MachoResolveObject(PyTuple objectData, PyInteger zero, CallInformation call)
 {
     /*
      * [0] => alliance or corp id
      * [1] => is master
      */
     return(this.BoundServiceManager.Container.NodeID);
 }
예제 #8
0
파일: NodeInfo.cs 프로젝트: Reve/EVESharp
        public PyObject Encode()
        {
            PyTuple packet = new PyTuple();

            packet.Items.Add(new PyInt(nodeID));
            packet.Items.Add(solarSystems);

            return new PyObjectData("machoNet.nodeInfo", packet);
        }
예제 #9
0
파일: alert.cs 프로젝트: ozatomic/EVESharp
        public PyDataType BeanCount(PyInteger stackID, PyDictionary namedPayload, object client)
        {
            PyTuple res = new PyTuple(2);

            res[0] = new PyNone();
            res[1] = new PyInteger(0);

            return(res);
        }
예제 #10
0
파일: alert.cs 프로젝트: sn0opy/EVESharp
        public PyDataType BeanCount(PyInteger stackID, CallInformation call)
        {
            PyTuple res = new PyTuple(2);

            res[0] = new PyNone();
            res[1] = new PyInteger(0);

            return(res);
        }
예제 #11
0
        public PyObject Encode()
        {
            PyTuple header = new PyTuple();

            header.Items.Add(new PyToken("blue.DBRowDescriptor"));
            header.Items.Add(columnList);

            return(new PyObjectEx(false, header));
        }
예제 #12
0
        /* This should never be used in the node, just the Cache Tool */
        public bool Decode(PyObject from)
        {
            PyTuple data = (from as PyObjectData).Arguments as PyTuple;

            // Just decode the cache info for now..
            cache = data.Items[4] as PyBuffer;

            return(true);
        }
예제 #13
0
        public void AddColumn(string name, FieldType type)
        {
            PyTuple column = new PyTuple();

            column.Items.Add(new PyString(name));
            column.Items.Add(new PyInt((int)type));

            ColumnList.Items.Add(column);
        }
예제 #14
0
 public void TestPyTupleInvalidAppend()
 {
     using (Py.GIL())
     {
         PyObject s = new PyString("foo");
         var      t = new PyTuple();
         Assert.Throws <PythonException>(() => t.Concat(s));
     }
 }
예제 #15
0
        public PyObject Encode()
        {
            PyTuple args = new PyTuple();

            args.Items.Add(session);
            args.Items.Add(new PyInt(clientID));

            return(new PyObjectData("macho.sessionInitialState", args));
        }
예제 #16
0
        public PyObject BeanCount(PyTuple args, object client)
        {
            PyTuple res = new PyTuple();

            res.Items.Add(new PyNone()); // Unique error ID, None for instant stack trace
            res.Items.Add(new PyInt(0)); // logging mode, 0 = local

            return(res);
        }
예제 #17
0
                public Sequential(params PythonObject[] modules) : base()
                {
                    var     nn       = self.GetAttr("nn");
                    var     __self__ = nn;
                    var     pyargs   = new PyTuple(modules.Select(m => m.PyObject as PyObject).ToArray());
                    dynamic py       = __self__.InvokeMethod("Sequential", pyargs);

                    self = py as PyObject;
                }
예제 #18
0
        public PyObject Encode()
        {
            PyTuple header = new PyTuple();

            header.Items.Add(new PyToken("blue.DBRowDescriptor"));
            header.Items.Add(columnList);

            return new PyObjectEx(false, header);
        }
        public void AddColumn(string name, FieldType type)
        {
            PyTuple column = new PyTuple();

            column.Items.Add(new PyString(name));
            column.Items.Add(new PyInt((int)type));

            columnList.Items.Add(column);
        }
예제 #20
0
파일: NodeInfo.cs 프로젝트: Tratos/EVESharp
        public PyObject Encode()
        {
            PyTuple packet = new PyTuple();

            packet.Items.Add(new PyInt(nodeID));
            packet.Items.Add(solarSystems);

            return(new PyObjectData("machoNet.nodeInfo", packet));
        }
예제 #21
0
        public PyObject Call(string svc, string call, PyTuple args, object client)
        {
            Service service = GetService(svc);

            if (service == null)
                return null;

            return service.Call(call, args, client);
        }
예제 #22
0
파일: Program.cs 프로젝트: Reve/beliEVE
 private IntPtr HandleLog(IntPtr self, IntPtr args)
 {
     var tup = new PyTuple(args);
     if (tup.IsInvalid || !tup.IsTuple || tup.Size <= 0)
         return PyObject.None;
     var obj = tup[0];
     Core.Log(LogSeverity.Minor, obj.ToString());
     return PyObject.None;
 }
예제 #23
0
파일: alert.cs 프로젝트: Reve/EVESharp
        public PyObject BeanCount(PyTuple args, object client)
        {
            PyTuple res = new PyTuple();

            res.Items.Add(new PyNone()); // Unique error ID, None for instant stack trace
            res.Items.Add(new PyInt(0)); // logging mode, 0 = local

            return res;
        }
예제 #24
0
        public bool CheckLowLevelVersionExchange(PyTuple packet)
        {
            LowLevelVersionExchange data = new LowLevelVersionExchange();

            if (data.Decode(packet) == false)
            {
                Log.Error("Client", "Wrong LowLevelVersionExchange packet");
                return(false);
            }

            if (data.birthday != Common.Constants.Game.birthday)
            {
                Log.Error("Client", "Wrong birthday in LowLevelVersionExchange");
                return(false);
            }

            if (data.build != Common.Constants.Game.build)
            {
                Log.Error("Client", "Wrong build in LowLevelVersionExchange");
                return(false);
            }

            if (data.codename != Common.Constants.Game.codename + "@" + Common.Constants.Game.region)
            {
                Log.Error("Client", "Wrong codename in LowLevelVersionExchange");
                return(false);
            }

            if (data.machoVersion != Common.Constants.Game.machoVersion)
            {
                Log.Error("Client", "Wrong machoVersion in LowLevelVersionExchange");
                return(false);
            }

            if (data.version != Common.Constants.Game.version)
            {
                Log.Error("Client", "Wrong version in LowLevelVersionExchange");
                return(false);
            }

            if (data.isNode == true)
            {
                if (data.nodeIdentifier != "Node")
                {
                    Log.Error("Client", "Wrong node string in LowLevelVersionExchange");
                    return(false);
                }

                Type = ConnectionType.Node;
            }
            else
            {
                Type = ConnectionType.Client;
            }

            return(true);
        }
예제 #25
0
        public PyObject Encode()
        {
            PyTuple args = new PyTuple();

            args.Items.Add(session);
            args.Items.Add(new PyInt(clientID));

            return new PyObjectData("macho.sessionInitialState", args);
        }
예제 #26
0
        public void VargsKeywordDefaults()
        {
            var co = new CodeObject(new byte[0]);

            co.ArgCount = 0;
            co.Defaults = new List <object>();
            co.VarNames.Add("args");
            co.VarNames.Add("a");
            co.VarNames.Add("b");
            co.Defaults   = new List <object>();
            co.KWDefaults = new List <object>();
            co.KWDefaults.Add(3);
            co.KWDefaults.Add(4);
            co.KWOnlyArgCount = 2;
            co.Flags         |= CodeObject.CO_FLAGS_VARGS;

            var inputs = new object[][]
            {
                new object[] { 1, 2 },
                new object[] { 1, 2 },
                new object[] { 1, 2 },
                new object[] { 1, 2 },
                new object[] { },
                new object[] { },
            };
            var keywordsIn = new Dictionary <string, object>[]
            {
                new Dictionary <string, object> {
                },
                new Dictionary <string, object> {
                    { "a", 200 }, { "b", 100 }
                },
                new Dictionary <string, object> {
                    { "a", 200 },
                },
                new Dictionary <string, object> {
                    { "b", 100 },
                },
                new Dictionary <string, object> {
                    { "a", 200 },
                },
                new Dictionary <string, object> {
                },
            };
            var outputs = new object[][]
            {
                new object[] { PyTuple.Create(new object[] { 1, 2 }), 3, 4 },
                new object[] { PyTuple.Create(new object[] { 1, 2 }), 200, 100 },
                new object[] { PyTuple.Create(new object[] { 1, 2 }), 200, 4 },
                new object[] { PyTuple.Create(new object[] { 1, 2 }), 3, 100 },
                new object[] { PyTuple.Create(new object[0]), 200, 4 },
                new object[] { PyTuple.Create(new object[0]), 3, 4 },
            };

            InOutTest(co, inputs, keywordsIn, outputs);
        }
예제 #27
0
        public UserError(PyTuple tuple, PyDict match)
        {
            if (match == null)
            {
                throw new InvalidDataException("UserError: No matching set found.");
            }
            if (tuple.Items.Count > 2 || tuple.Items.Count < 1)
            {
                throw new InvalidDataException("UserError: Invalid tuple size expected 1 or 2 got " + tuple.Items.Count);
            }
            PyString msgString = tuple.Items[0] as PyString;

            if (msgString == null)
            {
                throw new InvalidDataException("UserError: No message found.");
            }
            message = msgString.Value;
            if (tuple.Items.Count == 2)
            {
                dict = tuple.Items[1] as PyDict;
                if (dict == null)
                {
                    throw new InvalidDataException("UserError: Invalid dictionary.");
                }
            }
            msgString = match.Get("msg") as PyString;
            if (msgString == null || msgString.StringValue != message)
            {
                throw new InvalidDataException("UserError: Message name mismatch.");
            }
            PyRep matchRep = match.Get("dict");

            if (dict != null)
            {
                PyDict matchDict = matchRep as PyDict;
                if (matchDict == null)
                {
                    throw new InvalidDataException("UserError: No matching dictionary.");
                }
                if (matchDict.Dictionary.Count != dict.Dictionary.Count)
                {
                    throw new InvalidDataException("UserError: Dictionary size mismatch.");
                }
                //foreach(var kvp in dict.Dictionary)
                //{
                // To-DO: compare each entry.
                //}
            }
            else
            {
                if (matchRep != null && !(matchRep is PyNone))
                {
                    throw new InvalidDataException("UserError: No Dictionary to match.");
                }
            }
        }
예제 #28
0
        public void TupleUnmarshal_Empty()
        {
            PyDataType value = Unmarshal.ReadFromByteArray(sTupleMarshaling_Empty, false);

            Assert.IsInstanceOf <PyTuple>(value);

            PyTuple tuple = value as PyTuple;

            Assert.AreEqual(0, tuple.Count);
        }
 public PyPacket()
 {
     type = Macho.MachoNetMsg_Type.__Fake_Invalid_Type;
     type_string = "none";
     userID = 0;
     payload = null;
     named_payload = null;
     source = new PyAddress();
     dest = new PyAddress();
 }
예제 #30
0
 public void TestPyTupleValidConvert()
 {
     using (Py.GIL())
     {
         var     l = new PyList();
         PyTuple t = PyTuple.AsTuple(l);
         Assert.IsNotNull(t);
         Assert.IsInstanceOf(typeof(PyTuple), t);
     }
 }
예제 #31
0
        public void TestPyTupleBadCtor()
        {
            var     i = new PyInt(5);
            PyTuple t = null;

            var ex = Assert.Throws <ArgumentException>(() => t = new PyTuple(i));

            Assert.AreEqual("object is not a tuple", ex.Message);
            Assert.IsNull(t);
        }
예제 #32
0
        private IntPtr ReadDataPort(IntPtr self, IntPtr args)
        {
            var argTuple = new PyTuple(new PyObject(args, false));
            var portName = argTuple.Get(0).GetString();
            var dataPort = InputPorts.First(port => port.Name == portName) as NodeSystemLib2.FormatData1D.InputPortData1D;

            var buffer = dataPort.Read();

            return(new PyArray(buffer.Data.Take(buffer.Available).ToArray(), false).Object.Handle);
        }
예제 #33
0
        public void TestPyTupleValidAppend()
        {
            var t0 = new PyTuple();
            var t  = new PyTuple();

            t.Concat(t0);

            Assert.IsNotNull(t);
            Assert.IsInstanceOf(typeof(PyTuple), t);
        }
예제 #34
0
        public void NotifyCharacter(int characterID, string type, PyTuple notification)
        {
            // do not waste network resources on useless notifications
            if (this.CharacterManager.IsCharacterConnected(characterID) == false)
            {
                return;
            }

            this.SendNotification(type, NOTIFICATION_TYPE_CHARACTER, characterID, notification);
        }
예제 #35
0
        public void TestInvalidAsTuple()
        {
            var     i = new PyInt(5);
            PyTuple t = null;

            var ex = Assert.Throws <PythonException>(() => t = PyTuple.AsTuple(i));

            Assert.AreEqual("'int' object is not iterable", ex.Message);
            Assert.IsNull(t);
        }
예제 #36
0
        public DataType VisitTuple(PyTuple t)
        {
            TupleType tt = analyzer.TypeFactory.CreateTuple();

            foreach (var e in t.values)
            {
                tt.add(e.Accept(this));
            }
            return(tt);
        }
예제 #37
0
 public void TestNewPyTupleFromPyTuple()
 {
     using (Py.GIL())
     {
         var t0 = new PyTuple();
         var t  = new PyTuple(t0);
         Assert.IsNotNull(t);
         Assert.IsInstanceOf(typeof(PyTuple), t);
     }
 }
예제 #38
0
        private void HandleNotification(PyPacket packet, Client client)
        {
            if (packet.Source is PyAddressAny)
            {
                this.HandleBroadcastNotification(packet);
                return;
            }

            PyTuple callInfo = ((packet.Payload[0] as PyTuple)[1] as PySubStream).Stream as PyTuple;

            PyList objectIDs = callInfo[0] as PyList;
            string call      = callInfo[1] as PyString;

            if (call != "ClientHasReleasedTheseObjects")
            {
                Log.Error($"Received notification from client with unknown method {call}");
                return;
            }

            // search for the given objects in the bound service
            // and sure they're freed
            foreach (PyTuple objectID in objectIDs.GetEnumerable <PyTuple>())
            {
                if (objectID[0] is PyString == false)
                {
                    Log.Fatal("Expected bound call with bound string, but got something different");
                    return;
                }

                string boundString = objectID[0] as PyString;

                // parse the bound string to get back proper node and bound ids
                Match regexMatch = Regex.Match(boundString, "N=([0-9]+):([0-9]+)");

                if (regexMatch.Groups.Count != 3)
                {
                    Log.Fatal($"Cannot find nodeID and boundID in the boundString {boundString}");
                    return;
                }

                int nodeID  = int.Parse(regexMatch.Groups[1].Value);
                int boundID = int.Parse(regexMatch.Groups[2].Value);

                if (nodeID != this.Container.NodeID)
                {
                    Log.Fatal("Got a ClientHasReleasedTheseObjects call for an object ID that doesn't belong to us");
                    // TODO: MIGHT BE A GOOD IDEA TO RELAY THIS CALL TO THE CORRECT NODE
                    // TODO: INSIDE THE NETWORK, AT LEAST THAT'S WHAT CCP IS DOING BASED
                    // TODO: ON THE CLIENT'S CODE... NEEDS MORE INVESTIGATION
                    return;
                }

                this.BoundServiceManager.FreeBoundService(boundID);
            }
        }
예제 #39
0
파일: Service.cs 프로젝트: Reve/EVESharp
        public PyObject Call(string name, PyTuple args, object client)
        {
            ServiceCall call = GetServiceCall(name);

            if (call == null)
            {
                return new PyTuple();
            }

            return call.Run(args, client);
        }
예제 #40
0
        public void TestPyTupleStringConvert()
        {
            PyObject s = new PyString("foo");
            PyTuple  t = PyTuple.AsTuple(s);

            Assert.IsNotNull(t);
            Assert.IsInstanceOf(typeof(PyTuple), t);
            Assert.AreEqual("f", t[0].ToString());
            Assert.AreEqual("o", t[1].ToString());
            Assert.AreEqual("o", t[2].ToString());
        }
예제 #41
0
        public PyObject Encode()
        {
            PyTuple res = new PyTuple();

            PyTuple main = new PyTuple();

            main.Items.Add(new PyInt(clueless));
            main.Items.Add(changes);

            res.Items.Add(main);
            res.Items.Add(nodesOfInterest);

            return res.As<PyObject>();
        }
예제 #42
0
파일: CRowset.cs 프로젝트: Reve/EVESharp
        public PyObject Encode()
        {
            PyTuple args = new PyTuple();
            args.Items.Add(new PyToken("dbutil.CRowset"));

            PyDict dict = new PyDict();
            dict.Set("header", descriptor.Encode());

            PyObjectEx res = new PyObjectEx();
            res.IsType2 = true;

            args.Items.Add(dict);
            res.List = items.Items;

            return res;
        }
예제 #43
0
파일: Session.cs 프로젝트: Reve/EVESharp
        public PyDict EncodeChanges()
        {
            PyDict res = new PyDict();
            PyDict tmp = new PyDict();

            // Iterate through the session data
            foreach (PyString s in session.Dictionary.Keys)
            {
                PyTuple value = session[s].As<PyTuple>();

                PyObject last = value.Items[0];
                PyObject current = value.Items[1];

                // Check if they have the same type and value
                if (last != current)
                {
                    // Add the change to the dict
                    PyTuple change = new PyTuple();

                    change.Items.Add(last);
                    change.Items.Add(current);

                    res.Set(s.Value, change);

                    // Update the session with the new last value
                    PyTuple update = new PyTuple();

                    update.Items.Add(current);
                    update.Items.Add(current);

                    // We cant modify the session here, just store it on something temporal
                    tmp[s] = update;
                }
                else
                {
                    // We havent updated anything, but this would be later set as the session
                    // This will prevent the loss of session data
                    tmp[s] = value;
                }
            }

            // Send back the session from temporal to the final storage
            session = tmp;

            return res;
        }
예제 #44
0
파일: CacheDB.cs 프로젝트: Reve/EVESharp
        public static PyTuple GetCacheData(string name)
        {
            MySqlDataReader res = null;

            if (Database.Query(ref res, "SELECT cacheData, cacheTime, nodeID, version FROM cacheinfo WHERE cacheName='" + name + "';") == false)
            {
                return null;
            }

            if (res == null)
            {
                return null;
            }

            if (res.Read() == false)
            {
                res.Close();
                return null;
            }

            byte[] outb = null;

            try
            {
                outb = (byte[])res.GetValue(0);
            }
            catch (Exception)
            {
                Log.Error("CacheDB", "Cannot get cache data for cache " + name);
                res.Close();
                return null;
            }

            PyTuple tup = new PyTuple();
            tup.Items.Add(new PyBuffer(outb));
            tup.Items.Add(new PyLongLong(res.GetInt64(1)));
            tup.Items.Add(new PyIntegerVar(res.GetInt32(2)));
            tup.Items.Add(new PyIntegerVar(res.GetUInt32(3)));

            res.Close();

            return tup;
        }
예제 #45
0
            public override PyObject Run(PyTuple args, object client)
            {
                Log.Debug("objectCaching", "Called GetCachableObject stub");

                CacheInfo cache = new CacheInfo();

                if (cache.Decode(args) == false)
                {
                    return null;
                }

                Log.Debug("GetCachableObject", "Got cache request for cache " + cache.objectID.As<PyString>().Value);

                if (Cache.LoadCacheFor(cache.objectID.As<PyString>().Value) == false)
                {
                    return null;
                }

                return Cache.GetCache(cache.objectID.As<PyString>().Value);
            }
예제 #46
0
        // Who said me that this was painfull? :D Oh wait, It was me...
        // Nevermind, forget that, I found a way of do this using reflection
        // So this will be faster and painless
        public PyObject ServiceCall(string service, string call, PyTuple data, object client)
        {
            MethodInfo method = GetType().GetMethod(service);

            if (method == null)
            {
                throw new ServiceDoesNotExistsException(service);
            }

            Service svc = (Service)(method.Invoke(this, null));

            method = svc.GetType().GetMethod(call);

            if (method == null)
            {
                throw new ServiceDoesNotContainCallException(service, call);
            }

            return (PyObject)(method.Invoke(svc, new object[] { data, client }));
        }
예제 #47
0
파일: alert.cs 프로젝트: Reve/EVESharp
        public PyObject SendClientStackTraceAlert(PyTuple args, object client)
        {
            Log.Trace("SendClientStackTraceAlert", "Received client stack trace. Saving to a file");

            try
            {
                if (File.Exists("logs/stacktrace.txt") == false)
                {
                    File.Create("logs/stacktrace.txt");
                }

                File.AppendAllText("logs/stacktrace.txt", "------------------ " + args.Items[2].StringValue + " ------------------\n");
                File.AppendAllText("logs/stacktrace.txt", args.Items[0].As<PyTuple>().Items[1].StringValue);
                File.AppendAllText("logs/stacktrace.txt", args.Items[1].StringValue + "\n");
            }
            catch (Exception)
            {

            }

            // The client should receive anything to know that the stack trace arrived to the server
            return new PyNone();
        }
        public PyObject Encode()
        {
            PyTuple args = new PyTuple();

            // Command
            args.Items.Add(new PyInt((int)type));

            // Source
            args.Items.Add(source.Encode());

            // Dest
            args.Items.Add(dest.Encode());

            // unknown
            if (userID == 0)
                args.Items.Add(new PyNone());
            else
                args.Items.Add(new PyInt((int)userID));

            // Add call args( payload )
            args.Items.Add(payload);

            // Named arguments
            if (named_payload == null)
                args.Items.Add(new PyNone());
            else
                args.Items.Add(named_payload);

            return new PyObjectData(type_string, args);
        }
예제 #49
0
 private static string PrintTuple(PyTuple tuple)
 {
     return "[PyTuple " + tuple.Items.Count + " items]";
 }
        public PyObject Encode()
        {
            PyTuple header = new PyTuple();
            PyTuple args = new PyTuple();
            PyToken exception = new PyToken(exception_type);
            PyDict keywords = new PyDict();

            args.Items.Add(new PyString(reason));

            keywords.Set("reasonArgs", reasonArgs);
            keywords.Set("clock", new PyLongLong(clock));
            keywords.Set("region", new PyString(region));
            keywords.Set("reason", new PyString(reason));
            keywords.Set("version", new PyFloat(version));
            keywords.Set("build", new PyInt(build));
            keywords.Set("codename", new PyString(codename));
            keywords.Set("machoVersion", new PyInt(machoVersion));

            header.Items.Add(exception);
            header.Items.Add(args);
            header.Items.Add(keywords);

            return new PyObjectEx(false, header);
        }
예제 #51
0
파일: DBUtils.cs 프로젝트: Reve/EVESharp
        public static PyObject DBResultToTupleSet(ref MySqlDataReader result)
        {
            int column = result.FieldCount;
            if (column == 0)
                return new PyTuple();

            int r = 0;

            PyTuple res = new PyTuple();
            PyList cols = new PyList();
            PyList reslist = new PyList();

            for (r = 0; r < column; r++)
            {
                cols.Items.Add(new PyString(result.GetName(r)));
            }

            while (result.Read())
            {
                PyList linedata = new PyList();
                for (r = 0; r < column; r++)
                {
                    linedata.Items.Add(DBColumnToPyObject(r, ref result));
                }

                reslist.Items.Add(linedata);
            }

            res.Items.Add(cols);
            res.Items.Add(reslist);

            return res;
        }
        /*  From client/script/common/net/machonet.py line: 3864
         *  Client = ('clientID', 'callID', 'service')
         *  Broadcast = ('broadcastID', 'narrowcast', 'idtype')
         *  Node = ('nodeID', 'service', 'callID')
         *  Any = ('service', 'callID')
         */
        public PyObject Encode()
        {
            PyTuple t = new PyTuple();

            switch (type)
            {
                case AddrType.Any:
                    t.Items.Add( new PyString( "A" ));

                    if( service == "" )
                        t.Items.Add( new PyNone() );
                    else
                        t.Items.Add( new PyString( service ) );

                    if( typeID == 0 )
                        t.Items.Add(new PyNone());
                    else
                        t.Items.Add(new PyLongLong( (long)typeID ) );
                    break;

                case AddrType.Node:
                    t.Items.Add( new PyString( "N" ) );
                    t.Items.Add( new PyLongLong( (long)typeID ) );

                    if( service == "" )
                        t.Items.Add( new PyNone() );
                    else
                        t.Items.Add( new PyString( service ) );

                    if( callID == 0 )
                        t.Items.Add( new PyNone() );
                    else
                        t.Items.Add( new PyLongLong( (long)callID ) );

                    break;

                case AddrType.Client:
                    t.Items.Add( new PyString( "C" ) );
                    t.Items.Add(new PyLongLong((long)typeID));
                    t.Items.Add(new PyLongLong((long)callID));

                    if( service == "" )
                        t.Items.Add( new PyNone() );
                    else
                        t.Items.Add( new PyString( service ) );

                    break;

                case AddrType.Broadcast:
                    t.Items.Add( new PyString( "B" ) );

                    if( service == "" )
                        t.Items.Add( new PyNone() );
                    else
                        t.Items.Add( new PyString( service ) );

                    t.Items.Add( new PyList() );
                    t.Items.Add( new PyString( bcast_type ) );
                    break;

                default:
                    break;
            }

            return new PyObjectData( "macho.MachoAddress", t );
        }
예제 #53
0
        public static void HeartbeatNodes()
        {
            // Check if an older heartbeat left a node waiting
            foreach (int nodeID in nodeStatus.Keys)
            {
                if (nodes[nodeID] == null)
                {
                    continue;
                }

                if (nodeStatus[nodeID] == NodeStatus.NodeWaitingHeartbeat)
                {
                    // Node dead, load all the solarSystems into other node and transfer the clients
                    try
                    {
                        nodes.Remove(nodeID);
                    }
                    catch (Exception)
                    {

                    }
                }
            }

            PyTuple data = new PyTuple();

            data.Items.Add(new PyLongLong(DateTime.Now.ToFileTime()));

            NotifyNodes(new PyObjectData("macho.PingReq", data));
        }
예제 #54
0
파일: machoNet.cs 프로젝트: Reve/EVESharp
        public PyObject GetInitVals(PyTuple args, object client)
        {
            Log.Debug("machoNet", "Called GetInitVals stub");

            if (Cache.LoadCacheFor("machoNet.serviceInfo") == false)
            {
                // Cache does not exists, create it
                PyDict dict = new PyDict();

                dict.Set("trademgr", new PyString("station"));
                dict.Set("tutorialSvc", new PyString("station"));
                dict.Set("bookmark", new PyString("station"));
                dict.Set("slash", new PyString("station"));
                dict.Set("wormholeMgr", new PyString("station"));
                dict.Set("account", new PyString("station"));
                dict.Set("gangSvc", new PyString("station"));
                dict.Set("contractMgr", new PyString("station"));

                dict.Set("LSC", new PyString("location"));
                dict.Set("station", new PyString("location"));
                dict.Set("config", new PyString("locationPreferred"));

                dict.Set("scanMgr", new PyString("solarsystem"));
                dict.Set("keeper", new PyString("solarsystem"));

                dict.Set("stationSvc", new PyNone());
                dict.Set("zsystem", new PyNone());
                dict.Set("invbroker", new PyNone());
                dict.Set("droneMgr", new PyNone());
                dict.Set("userSvc", new PyNone());
                dict.Set("map", new PyNone());
                dict.Set("beyonce", new PyNone());
                dict.Set("standing2", new PyNone());
                dict.Set("ram", new PyNone());
                dict.Set("DB", new PyNone());
                dict.Set("posMgr", new PyNone());
                dict.Set("voucher", new PyNone());
                dict.Set("entity", new PyNone());
                dict.Set("damageTracker", new PyNone());
                dict.Set("agentMgr", new PyNone());
                dict.Set("dogmaIM", new PyNone());
                dict.Set("machoNet", new PyNone());
                dict.Set("dungeonExplorationMgr", new PyNone());
                dict.Set("watchdog", new PyNone());
                dict.Set("ship", new PyNone());
                dict.Set("DB2", new PyNone());
                dict.Set("market", new PyNone());
                dict.Set("dungeon", new PyNone());
                dict.Set("npcSvc", new PyNone());
                dict.Set("sessionMgr", new PyNone());
                dict.Set("allianceRegistry", new PyNone());
                dict.Set("cache", new PyNone());
                dict.Set("character", new PyNone());
                dict.Set("factory", new PyNone());
                dict.Set("facWarMgr", new PyNone());
                dict.Set("corpStationMgr", new PyNone());
                dict.Set("authentication", new PyNone());
                dict.Set("effectCompiler", new PyNone());
                dict.Set("charmgr", new PyNone());
                dict.Set("BSD", new PyNone());
                dict.Set("reprocessingSvc", new PyNone());
                dict.Set("billingMgr", new PyNone());
                dict.Set("billMgr", new PyNone());
                dict.Set("lookupSvc", new PyNone());
                dict.Set("emailreader", new PyNone());
                dict.Set("lootSvc", new PyNone());
                dict.Set("http", new PyNone());
                dict.Set("repairSvc", new PyNone());
                dict.Set("gagger", new PyNone());
                dict.Set("dataconfig", new PyNone());
                dict.Set("lien", new PyNone());
                dict.Set("i2", new PyNone());
                dict.Set("pathfinder", new PyNone());
                dict.Set("alert", new PyNone());
                dict.Set("director", new PyNone());
                dict.Set("dogma", new PyNone());
                dict.Set("aggressionMgr", new PyNone());
                dict.Set("corporationSvc", new PyNone());
                dict.Set("certificateMgr", new PyNone());
                dict.Set("clones", new PyNone());
                dict.Set("jumpCloneSvc", new PyNone());
                dict.Set("insuranceSvc", new PyNone());
                dict.Set("corpmgr", new PyNone());
                dict.Set("warRegistry", new PyNone());
                dict.Set("corpRegistry", new PyNone());
                dict.Set("objectCaching", new PyNone());
                dict.Set("counter", new PyNone());
                dict.Set("petitioner", new PyNone());
                dict.Set("LPSvc", new PyNone());
                dict.Set("clientStatsMgr", new PyNone());
                dict.Set("jumpbeaconsvc", new PyNone());
                dict.Set("debug", new PyNone());
                dict.Set("languageSvc", new PyNone());
                dict.Set("skillMgr", new PyNone());
                dict.Set("voiceMgr", new PyNone());
                dict.Set("onlineStatus", new PyNone());
                dict.Set("gangSvcObjectHandler", new PyNone());

                Cache.SaveCacheFor("machoNet.serviceInfo", dict, DateTime.Now.ToFileTimeUtc());
            }

            PyObject srvInfo = Cache.GetCacheData("machoNet.serviceInfo");
            PyTuple res = new PyTuple();
            PyDict initvals = new PyDict();

            res.Items.Add(srvInfo);
            res.Items.Add(initvals); // Rest of the cache data

            return res;
        }
예제 #55
0
파일: machoNet.cs 프로젝트: Reve/EVESharp
 public PyObject GetTime(PyTuple args, object client)
 {
     return new PyLongLong(DateTime.Now.ToFileTimeUtc());
 }
예제 #56
0
파일: Program.cs 프로젝트: yushiro/beliEVE
 private IntPtr HandleTest(IntPtr self, IntPtr args)
 {
     Core.Log(LogSeverity.Minor, "In HandleTest");
     var tup = new PyTuple(args);
     foreach (var obj in tup)
         Core.Log(LogSeverity.Minor, "arg: " + obj);
     return new PyInt(1).Pointer;
 }
예제 #57
0
파일: Parser.cs 프로젝트: uxmal/pytocs
//raise_stmt: 'raise' [test ['from' test]]
//raise_stmt: 'raise' [test [',' test [',' Test]]]
        public Statement raise_stmt()
        {
            Exp exToRaise = null;
            Exp exOriginal = null;
            var token = Expect(TokenType.Raise);
            var posStart = token.Start;
            var posEnd = token.End;
            if (!Peek(stmt_follow))
            {
                exToRaise = test();
                posEnd = exToRaise.End;
                if (PeekAndDiscard(TokenType.From))
                {
                    exOriginal = test();
                    posEnd = exOriginal.End;
                }
                else if (PeekAndDiscard(TokenType.COMMA))
                {
                    Exp ex2 = test();
                    Exp ex3 = new NoneExp(filename, ex2.End, ex2.End);
                    if (PeekAndDiscard(TokenType.COMMA))
                    {
                        ex3 = test();
                    }
                    exOriginal = new PyTuple(new List<Exp> { ex2, ex3 }, filename, posStart, (ex3 ?? ex2).End);
                    posEnd = exOriginal.End;
                }
            }
            return new RaiseStatement(exToRaise, exOriginal, filename, posStart, posEnd);
        }
예제 #58
0
 public void VisitTuple(PyTuple tuple)
 {
     throw new NotImplementedException();
 }
        public bool Decode( PyObject data )
        {
            PyObject packet = data;

            if (packet.Type == PyObjectType.ChecksumedStream)
            {
                packet = packet.As<PyChecksumedStream>().Data;
            }

            if (packet.Type == PyObjectType.SubStream)
            {
                packet = packet.As<PySubStream>().Data;
            }

            if (packet.Type != PyObjectType.ObjectData)
            {
                return false;
            }

            PyObjectData packeto = packet.As<PyObjectData>();

            type_string = packeto.Name;

            if (packeto.Arguments.Type != PyObjectType.Tuple)
            {
                return false;
            }

            PyTuple tuple = packeto.Arguments.As<PyTuple>();

            if (tuple.Items.Count != 6)
            {
                return false;
            }

            if ((tuple.Items[0].Type != PyObjectType.IntegerVar) && ( tuple.Items[0].Type != PyObjectType.Long ) )
            {
                return false;
            }

            PyInt typer = tuple.Items[0].As<PyInt>();

            type = (Macho.MachoNetMsg_Type)typer.Value;

            if (!source.Decode(tuple.Items[1]))
            {
                return false;
            }

            if (!dest.Decode(tuple.Items[2]))
            {
                return false;
            }

            if ((tuple.Items[3].Type == PyObjectType.IntegerVar) || (tuple.Items[3].Type == PyObjectType.Long) )
            {
                userID = (uint)tuple.Items[3].As<PyInt>().Value;
            }
            else if (tuple.Items[3].Type == PyObjectType.None)
            {
                userID = 0;
            }
            else
            {
                return false;
            }

            // Payload( or call arguments )
            if ((tuple.Items[4].Type != PyObjectType.Buffer) && (tuple.Items[4].Type != PyObjectType.Tuple))
            {
                return false;
            }

            payload = tuple.Items[4].As<PyTuple>();

            if (tuple.Items[5].Type == PyObjectType.None)
            {
                named_payload = new PyDict();
            }
            else if (tuple.Items[5].Type == PyObjectType.Dict)
            {
                named_payload = tuple.Items[5].As<PyDict>();
            }
            else
            {
                return false;
            }

            return true;
        }
예제 #60
0
파일: Session.cs 프로젝트: Reve/EVESharp
        private void _Set(PyObject key, PyObject val)
        {
            if (session.Dictionary.ContainsKey(key) == false)
            {
                PyTuple var = new PyTuple();

                var.Items.Add(new PyNone());
                var.Items.Add(val);

                session.Dictionary.Add(key, var);
            }
            else
            {
                PyTuple tmp = session.Dictionary[key].As<PyTuple>();

                tmp.Items[0] = tmp.Items[1];
                tmp.Items[1] = val;

                session.Dictionary[key] = tmp;
            }
        }